Re: [Java-gnome-developer] FileSelection Dialog
Brought to you by:
afcowie
From: Andrew <ac...@on...> - 2003-12-06 19:54:48
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Luca De Rugeriis wrote: | 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. | Thanks, I'll give it a go. The code I provided was just an example, yes the local variable won't be of any use, but in reality I won't be using a local var, I was just trying to debug it :) - -- [A n d r e w] - ------|------ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQE/0jPu2AKtqeH2FeQRAoSLAJ9EXz/0b1L67FWPAKssrAVsG50GrgCfcWgc nbsfqq8fpIPbiMwk7HDlVLw= =BKlO -----END PGP SIGNATURE----- |