How can I make a JFileChooser on the Mac that lets users create directories?

爱⌒轻易说出口 提交于 2019-12-23 14:21:24

问题


I have an installer program that lets the user choose a directory in which to install. The JFileChooser implementation on MacOS uses a native dialog (or at least it looks native). That's great.

The only problem is there's no way to create a directory from this dialog ... you can only choose a pre-existing one, which is clunky. Is there a way to get this functionality?

I use the JFileChooser in "select directories only" mode. Thus it isn't the same dialog as the usual MacOS file picker which does have that functionality.


回答1:


That is correct that the showOpenDialog method will not give you an option to create new folders. This is a usability thing as it does not really make sense to open something that does not exist. If you use the showSaveDialog there will be a button 'Make new Folder' or similar to that.




回答2:


public static void main(String[] args) {
    JFrame frame = new JFrame();
    FileDialog d = new FileDialog(frame);
    d.setVisible(true);
}


来源:https://stackoverflow.com/questions/845403/how-can-i-make-a-jfilechooser-on-the-mac-that-lets-users-create-directories

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