Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JFileChooser does not recognize the external OS behavior

 
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?
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • 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
 
It is no measure of health to be well adjusted to a profoundly sick society. -Krishnamurti Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic