JFileChooser vs JDialog vs FileDialog

我与影子孤独终老i 提交于 2019-12-22 10:59:50

问题


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.


回答1:


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()).



来源:https://stackoverflow.com/questions/9796800/jfilechooser-vs-jdialog-vs-filedialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!