JFileChooser vs JDialog vs FileDialog [英] JFileChooser vs JDialog vs FileDialog
问题描述
我需要知道3对哪一个最适合我。我的要求按重要性排列如下:
I need to know which of the 3 is best for me. My requirements are as follows in order of importance:
- 轻松保存和加载文件。
- 文件类型过滤 文件选择期间(之后)。
- 外观与完全相同,与本机操作系统L& F相同。
- 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.
推荐答案
您的应用程序的其余部分是什么?如果你使用AWT,你应该使用 FileDialog
。如果你使用Swing,你应该使用 JFileChooser
。这两个类都满足您的所有要求。 ( JDialog
只是一个空窗口,如果你向它添加 Component
,你只能使用它来打开文件,而 JFileChooser
已经为你做了这个。)
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.)
保存和加载必须用你自己的方法写, JFileChooser
和 FileDialog
只能用于选择文件。
Saving and loading has to be written with your own methods, both JFileChooser
and FileDialog
can only be used to select file(s).
两者 FileDialog的
和 JFileChooser
在选择期间支持文件过滤器。
Both FileDialog
and JFileChooser
support file filters during selection.
FileDialog
的默认UI是本机操作系统'。 JFileChooser
(实际上,您的整个应用程序)UI可以使用 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())设置为本机操作系统
。
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())
.
这篇关于JFileChooser vs JDialog vs FileDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!