Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JFileChooser vs JDialog vs FileDialog

I need to know which of the 3 is best for me. My requirements are as follows in order of importance:

  • Save and load files with ease.
  • File type filter during file selection (not afterwards).
  • Look and feel is exactly the same as the native OS L&F.

If there is a dialog that I've not mentioned that would be more ideal, please let me know.

like image 973
Perry Monschau Avatar asked Sep 16 '25 08:09

Perry Monschau


1 Answers

What is the rest of your application written in? If you used AWT you should use FileDialog. If you used Swing you should use JFileChooser. Both classes meet all of your requirements. (A JDialog is simply an empty window, you can only use it to open files if you add a Component to it which allows you to, and JFileChooser already does this for you.)

Saving and loading has to be written with your own methods, both JFileChooser and FileDialog can only be used to select file(s).

Both FileDialog and JFileChooser support file filters during selection.

FileDialog's default UI is the native OS'. JFileChooser's (in fact, your entire applicatin's) UI can be set to the native OS' with UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()).

like image 93
Jeffrey Avatar answered Sep 19 '25 14:09

Jeffrey