Bonjour, je suis en train de faire une appli avec interface SWT mais j'ai un petit probleme

J'ai sur mon interface un bouton "Browse" qui doit permettre à l'utilisateur de choisir un fichier à ouvrir dans certaines fonctions de traitement.
Le nom du fichier se marque bien dans une zone de texte à coté. Le probleme est que en dehors de ce bloc d'action je ne peux pas récupérer le nom de mon fichier, ce qui me permettrait d'appeler des fonctions
ayant besoin de ce nom de fichier (je veux récupérer nomFichierAOuvrir):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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); 
        } 
     } 
});