Two options come to mind. One way is to traverse the Component hierarchy, identify the JToggleButton and either disable or remove it. The other way is to extend and alter the plaf code to customize the ui; this is often fairly straight-forward. For JFileChooser this leads us to the MetalFileChooserUI in which the ui components are assembled. In the source code (j2se 1.5) for this class, just under the class declaration, is this comment: // Much of the Metal UI for JFilechooser is just a copy of // the windows implementation, but using Metal themed buttons, lists, // icons, etc. We are planning a complete rewrite, and hence we've // made most things in this class private. So you would end up copying and modifying almost the entire class to get anything useful.
Thank you Craig for this excellent code: this is exactly what i need & it works great !
BTW : for the treetable dnd issue; it caused me lots of problems especially on Mac os platform.so i gave up and tried to switch to a Filechooser which i suppose is simpler.
I'm happy now i have the details view of filechooser as default (thanks to your excellent code). I'm now looking to add DnD to my filechooser as i did for treetable before (u remember ?) i want to be able to drag multiple files /folders from filechooser and drop them to right JTable as in my previous code. I wonder if you can assist me on this if you have enough time that would be very nice from your part.
My God : those Macs are driving me crazy ! I tested the java code on the Mac but didn't get the details view.. it seems Mac is using it's own view Mode different from win & Linux. I'm stuck with theses Macs OS :they refuse to run my java code whatever I'm doing..and they say java is cross platform !!!
any way I hope i can implement dnd for filechooser at least.
Hi Craig, I have a java code to hack the FileChooserUI class below... i think we can extract the Panel createDetailsView() but the problem is there are no event listner registered on this JPanel. is that correct ? if i display this JPanel in a JFrame and double click a folder nothing happens.
can we extract this Jpanel with all event registered as in original JFileChooser ?
I didn't have much patience for trying to extract components from the MetalFileChooserUI. It seems that it's the filePanel that you'd want from it. So I made up a custom component to look like the filePanel component used in the JFileChooser. I set in the top of a JFrame with no controls to create a minimal demonstration of drag_n_drop/copy_paste to the similarly-configured JTable in the bottom half. The app successfully copies to Wordpad as well as drop/pasting to the drop (lower) table. I used all String types in the fileTable (top) component for simplicity.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop