在我之前的一个 Netbeans 平台应用程序中,我使用此代码来打开一个保存对话框
File home = new File(System.getProperty("user.dir"));
XMLfile = new org.openide.filesystems.FileChooserBuilder("_output")
.setTitle("Save Dictionary")
.setDefaultWorkingDirectory(home)
.setApproveText("Save")
.setFileFilter(new FileNameExtensionFilter("xml files (*.xml)", "xml"))
.setAcceptAllFileFilterUsed(true)
.showSaveDialog();
出于某种原因,在我当前的 Netbeans 平台应用程序中,Netbeans IDE 找不到 org.openide.filesystems.FileChooserBuilder
(javadoc)。我的模块声明对 File System API
的依赖,据我所知,它“导入”了命名空间 org.openide.filesystems
.
我找不到任何FileChooserBuilder
的信息已被弃用,我也没有找到替代建议。
Netbeans IDE 建议使用 javafx.stage.FileChooser
相反,但我在 new javafx.stage.FileChooser.FileChooser().showSaveDialog(Window ownerWindow)
上遇到了麻烦因为我不知道如何获取Window
来 self 的TopComponent
。如果我通过null
,抛出异常( IllegalStateException: This operation is permitted on the event thread only; currentThread = AWT-EventQueue-0
),可能是因为 null
导致非模式对话框。
那么org.openide.filesystems.FileChooserBuilder
在哪里?消失了,或者我的错误在哪里?
最佳答案
由于某种原因它又可以工作了。我已经删除了对文件系统 API 的依赖,在该项目上工作了几天,然后再次添加了它。也许我已经清除了 Netbeans 缓存(在 %localappdata%
中)和所有模块的 /build
目录。不确定是什么解决了问题。
关于java - Netbeans 平台应用程序中的 FileChooserBuilder 丢失?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45277569/