• Post Reply Bookmark Topic Watch Topic
  • New Topic

JFileChooser does not recognize the external OS behavior

 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While the JFileChooser is opened I created a new folder externally to the location I am viewing from file chooser. But it did not recognize the folder creation. Once I refresh the window it is there. So I have to refresh the window to every time I do a modification externally. So is there any solution?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dilshan Edirisuriya:
While the JFileChooser is opened I created a new folder externally to the location I am viewing from file chooser. But it did not recognize the folder creation. Once I refresh the window it is there. So I have to refresh the window to every time I do a modification externally. So is there any solution?


Before JFileChooser displays the dialog, it scans the directory structure. If you are creating a folder after the dialog is visible, there is no mechanism to update the dialog automatically.
Theoretically , you can do the following:
1) Open the dialog
2) Spawn a thread which will keep on monitoring the FS
3) As soon as it figures out any structural change it can fire a notification.
4) Subclass JFileChooser.
5) Subscribe to these notifications
6) On being notified reload the contents.

I wonder if its worth it.
[ August 04, 2008: Message edited by: Maneesh Godbole ]
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Maneesh. May be that will be the solution for the problem. In some scenarios I had to do like that. For OK button validation, OK and Cancel button key events I had to find the appropriate component. I was checking whether there are any basic solution for that.

Thank you
 
Paper has not yet been outlawed – so let your Java Swing application print with wild abandon: JPDF
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!