Forums Register Login

disabling the view of files in Jtree

+Pie Number of slices to send: Send
hi,
i was wondering if it is possible to display only the directories, exculding the files. that is it should look like the folders pane of windows explorer. if so how do we go about it.
thanks
saurabh sood
[ May 28, 2003: Message edited by: saurabh sood ]
+Pie Number of slices to send: Send
Are you asking about JTree or about JFileChooser?

If you are talking about JFileChooser (which I'll assume you mean since you are talking about files, and you'd have to customize JTree to deal with files. ) all you have to do is create a subclass of javax.swing.filechooser.FileFilter that implements the accept() method like this :

then pass this file filter into the setFileFilter() method of the JFileChooser.
+Pie Number of slices to send: Send
hi,
thanks for replying. my real objective is to create a batch utility, that performs a set of tasks to all the files in that directory. the user selects the directory. i do know how to make only directory visible in JFileChooser.
that can be done by
JFileChooser jfc = new JFileChooser();
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
is it possible to display only directories in JTree
thanks in advance
saurabh sood
+Pie Number of slices to send: Send
To show directories in a JTree, you would do something like the following:

It's a tiny ad. At least, that's what she said.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2280 times.
Similar Threads
RequestDispatcher
java.lang.NoDefFoundError
extract content from table
PopUp
Method which isn't a constructor should have a return type
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:07:46.