Re: [Java-gnome-developer] FileSelection Dialog
Brought to you by:
afcowie
From: Luca De R. <pie...@li...> - 2003-12-06 19:35:14
|
Il sab, 2003-12-06 alle 01:19, Andrew ha scritto: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hoping someone can help me with what should be quite straight forward! > > I have a the following code: > > final FileSelection dialog = new FileSelection("Select File"); //why final? > > dialog.setModal(true); > dialog.addListener(new DialogListener() { > public boolean dialogEvent(DialogEvent event) { > if (event.isOfType(DialogEvent.Type.RESPONSE)) { > String filename = dialog.getFilename(); > } > > ((Dialog) event.getSource()).destroy(); dialog.destroy(); //isn't it enough? > return true; //the returned value goes nowhere... > } > }); > dialog.show(); > > > So what happens is the file selection dialog opens. I select my file > (say /home/work/build.xml) and click oK, the filename variable correctly > contains the selected file. > Now the problem is, if I select this file, but click cancel. > I still end up with text in my filename variable, when I want it to > contain nothing, because I didn't really choose a file. > > Anyone clear this up for me? Apart that I can't see how that filename variable can be of use, since it's a local var, if I were you I would simply add a listener to the cancel button: it should respond to a click event first clearing the filename var (it should be a instance var), then destroyng the dialog ;) It's sipmle as it sounds Luca. -- Luca De Rugeriis <pie...@li...> |