1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
   |  
final Button button = new Button(shell, SWT.NONE);
button.addSelectionListener(new SelectionAdapter() 
{ 
    public void widgetSelected(SelectionEvent e) 
    { 
    } 
}); 
button.setBounds(420, 20, 65, 25); 
button.setText("Browse"); 
 
Label lblNomFichier = new Label(shell, SWT.NONE); 
lblNomFichier.setBounds(10, 30, 100, 25); 
lblNomFichier.setText("Nom du fichier : "); 
final Text txtNomFichier = new Text(shell, SWT.BORDER); 
txtNomFichier.setBounds(110, 20, 275, 25); 
txtNomFichier.setText(""); 
txtNomFichier.setSize(300, 30); 
 
button.addListener(SWT.Selection, new Listener() 
{ 
     public void handleEvent(Event e) 
     { 
         String nomFichierAOuvrir; 
         FileDialog dialog = new FileDialog(shell, SWT.OPEN); 
         dialog.setFilterExtensions(new String[] { "*.txt", "*.erc" }); 
         nomFichierAOuvrir = dialog.open(); 
         if ((nomFichierAOuvrir != null) && (nomFichierAOuvrir.length() != 0)) 
        { 
             txtNomFichier.setText(nomFichierAOuvrir); 
        } 
     } 
}); | 
Partager