Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I write a Java directory chooser?

Tags:

java

directory

How can I write a directory chooser as like that:

enter image description here

or: enter image description here

at Java?

PS 1: I am developing a desktop application and I use Swing at my application.

PS 2: I want to list just directories.

like image 627
kamaci Avatar asked Feb 14 '26 02:02

kamaci


1 Answers

You could use a TreeTable, here's a directory scanner using a treetable with a pretty decent tutorial: http://java.sun.com/products/jfc/tsc/articles/treetable1/

Your second picture looks just like JFileChooser...

      JFileChooser fileChooser = new JFileChooser(file);
      fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

If you want to change it's behavior just create a MyFileChooser class that extends JFileChooser.

like image 84
Federico Vera Avatar answered Feb 16 '26 15:02

Federico Vera



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!