I wrap up JFileChooser into a function so that each time there is an need to browse a file, I simply call chooseFile() to get a
string.
Here are several issues with this piece of code:
1) It does not remember the directory I go to last time. The first time I used it it set path to "Documents and Settings\user\My Documents". I change it to say "c:\products\database" and pick up "emp.txt", next time I want to select "c:\products\database\dept.txt", when bringup this dialog, it comes back to "Documents and Settings\user\My Documents" again. I am so sick of this stupid behaviour. Is there any way to work around this issue? I know
Java probably does not have the ability to persist most recent used file operation like Windows does, but I expect at least during a client session it can remember what user does last time.
2. Make this dialog on top.
Here is the case:
1) I start my client app.
2) Select File --> New menu and it bring up this FileChoose dialog
3) Then switch to some other application such as Explorer, do something else.
4) Come back. Note that in the windows task bar it only list client app, so I click that one to activate it. This is the sick behaviour again: client app does show up, but the dialog is hiding somewhere, and client app is disabled as well. Why can't java bring up this dialog up just like any other thing you would expect, such as Notepad? Maybe I can change code to parse in a JFrame and use it here:
chooser.showOpenDialog( frame );
But I think this is really stupid.
Any suggestions are welcome!