• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JFileChooser problem

 
Eric Kim
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!

 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure I can help you out with your second question -- it seems all programs do that! As far as the first question, you can always persist the directory information so that the next time, you can set the starting directory for the file chooser before it is initially displayed.
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric,
As Nathaniel suggested, persist the databaseFile (in suncertify.properties) and then you can do the following:

I don't know how to prevent your second problem, where a Java dialog lurks behind other windows. I've seen it happen and have had to minimize all the other windows in order to find the hidden dialog.
 
Eric Kim
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks George!
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric,
If you still want to figure out the hidden dialog problem I suggest you post it at this forum: Swing / JFC / AWT .
If anyone knows the answer, it's probably someone there.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic