如何在Mac上制作允许用户创建目录的JFileChooser? [英] How can I make a JFileChooser on the Mac that lets users create directories?

查看:38
本文介绍了如何在Mac上制作允许用户创建目录的JFileChooser?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个安装程序,该程序可让用户选择要安装的目录. MacOS上的JFileChooser实现使用本地对话框(或至少看起来是本地对话框).那太棒了.

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?

我在仅选择目录"模式下使用JFileChooser.因此,它与具有该功能的通常的MacOS文件选择器不同,它不是一个对话框.

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.

推荐答案

很正确,showOpenDialog方法不会为您提供创建新文件夹的选项.这是一个可用性问题,因为打开不存在的东西实际上没有任何意义.如果您使用showSaveDialog,将出现一个新建文件夹"或类似的按钮.

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.

这篇关于如何在Mac上制作允许用户创建目录的JFileChooser?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆