This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java and have Dr. Raoul-Gabriel Urma & Richard Warburton on-line!
See this thread for details.
Win a copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

JFileChooser problem

 
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!

 
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.
 
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.
 
If you two don't stop this rough-housing somebody is going to end up crying. Sit down and read this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!