• Post Reply Bookmark Topic Watch Topic
  • New Topic

JFileChooser loses focus when clicked away and back  RSS feed

 
Jeff Grant
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an application which is using a couple of JFileChooser variables for Open and Save dialogs.

While the dialog is open, if I click the task bar (Windows XP Professional) to another program and then click back to my Java app, the dialog is behind the primary JFrame.

I can Alt-Tab to the dialog box, but since I am not the only user of this application, I feel it would be best to somehow get thie dialog to remain on top of the JFrame.

I did some searching (here and google) but could not find a fix for this if there is one available.

Thanks in advance.
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you passing in a non-null parent when creating the file chooser dialog?
 
Jeff Grant
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Carman:
Are you passing in a non-null parent when creating the file chooser dialog?

No.
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you pass in a null parent, it will have this behavior.
 
Jeff Grant
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Carman:
If you pass in a null parent, it will have this behavior.

You're right, for some reason the container public global variable is null within the listener. I will try to find something else to pass it and will keep you posted.

Thanks!
 
Jeff Grant
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, fixed it.. I put a public JPanel in there instead of my parent container.

I still am not sure why the container is null, but so be it.

Thanks for your help James!
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem. Glad to help!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!