aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Problem using FileChooser.readOnly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem using FileChooser.readOnly " Watch "Problem using FileChooser.readOnly " New topic
Author

Problem using FileChooser.readOnly

Tina Viessmann
Greenhorn

Joined: Jun 01, 2011
Posts: 8
Hi,

I've tried to disable the create new folder and rename for a JFileChooser. I know I can use the client property FileChooser.readOnly. I've experiencing some difficulties using that.
Because I only wanted to change the property for one specific file chooser, i've tried:Unfortunately that does not work. But this way i've alread used successfully :
I know I can useBut I don't want to fool arround with the UIManager.

Does anyone have any ideas?

Thank you!
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2225
    
    8


In case you are wondering how I knew what the Action name was check out the article on Key Bindings.
Tina Viessmann
Greenhorn

Joined: Jun 01, 2011
Posts: 8
Hi Rob, thank you for your solution. Unfortunately its not exactly what I'm looking for. I want to remove the 'New Folder' option from the menue and disable the rename functionality for files/folders. (when you double click the file/folder slowly, you can rename it.)
That's what setting the client property should do.

Thank you anyway.

~Tina
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2225
    
    8
I see what you mean. I"ve searched all through the source code and can't figure out how the "readOnly" property affects the ability to rename a file.

I suggest you use the UIManager for this. I don't see any downside to your original approach.

I also asked this question with a few more details and a few more code examples that shows what I've tested at: https://forums.oracle.com/forums/thread.jspa?threadID=2298004&tstart=0, if you want to follow that posting as well. If any new information comes up I'll post it here.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
If folder navigation is not required, perhaps just loading the filenames into a JList might suit
Tina Viessmann
Greenhorn

Joined: Jun 01, 2011
Posts: 8
@Rob
Thank you for your effort! I've read your other thread and it describes my problem very well. Let's see what solution results from this.

@Michael
Unfortunately folder navigation is needed. Otherwise I would have put it into a list. Thank you anyway.
J. Kleopatra
Greenhorn

Joined: Feb 01, 2011
Posts: 1
Actually, I'm surprised that read-only is not a property of the fileChooser, doooh ...

But I don't see any downside with temporarily changing a UIManager value, practically, just make sure you reset the value to the original:



Fiddling with deeply hidden implementation details is far worse ;-)

Cheers
Jeanette
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem using FileChooser.readOnly