Alternative to JFileChooser

旧时模样 提交于 2019-11-27 19:07:07

You can also try XFileDialog. Haven't tried it much yet but looks worth evaluating.

The AWT FileDialog actually does use the native component, but as with most AWT vs. Swing issues, it's much less flexible and customizable than Swing's JFileChooser. So there's a tradeoff: JFileChooser may have a clunky user interface, but it's usually better for most purposes. If you really want your file choosing dialogs to look and feel like the native ones, though, then you can go with FileDialog.

I know this is a little late, but it may help other users. You can customize the UI of an application to the UI of the OS:

try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {e.printStackTrace();     }

I wrote a wrapper around JavaFX' file chooser if available. If included in your application, you can replace

JFileChooser fileChooser = new JFileChooser();

with

JFileChooser fileChooser = new NativeJFileChooser();

It will then use the native (and modern) file chooser of the underlying platform. Not everything works 100% the same, so make sure to test it afterwards, but most things should go smoothly.

As @htw said use FileDialog if the look and feel is your main concern. By using FileDialog be aware that there a lots of convenience methods that you won't be able to use...

I used VFSJFileChooser few times. It doesn't suffer from the JFileChooser bugs(slow to load because of zip files, windows only), but the interface is not "native".

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