简体   繁体   English

javaFX 2.0 如何 select 文件又名 FileChooser

[英]javaFX 2.0 how to select files aka FileChooser

I'm trying out the new JavaFx 2.0 beta release but cannot find anyway of selecting files using a dialog box like JfileChooser.我正在尝试新的 JavaFx 2.0 beta 版本,但无论如何都找不到使用 JfileChooser 之类的对话框选择文件。

Any ideas on how to do this?关于如何做到这一点的任何想法?

Thanks谢谢

At present there aren't any file chooser dialogs available in JavaFX 2.0 beta.目前 JavaFX 2.0 beta 中没有任何可用的文件选择器对话框。 Your best option in the short-term is to use a TreeView and browse your file system with that.短期内您最好的选择是使用 TreeView 并用它浏览您的文件系统。 Creating a TreeView file system browser is rather simple.创建 TreeView 文件系统浏览器相当简单。

You can use form filechoser - as you know swing components can used in javafx 2.0.您可以使用表单文件选择器 - 如您所知,swing 组件可以在 javafx 2.0 中使用。

 b.setLayoutY(50);
b.setOnMouseClicked(new EventHandler<MouseEvent>() {

        public void handle(MouseEvent event) {
            JFileChooser fileChooser = new JFileChooser();
            fileChooser.showDialog(javafxPanel, null);

        }
    });

Since JavaFX 2.1 you can use an object of class javafx.stage.DirectoryChooser .从 JavaFX 2.1开始,您可以使用 object 的 class ZD4365F262EFB00844DDCE05B80DE0 7

mehdi is correct that you can use JFileChooser in your FX 2.0 app. mehdi 是正确的,您可以在 FX 2.0 应用程序中使用 JFileChooser。 I am doing it also.我也在做。 However, it's not correct to say that you can use swing components inside of JavaFX 2.0: http://javafx-jira.kenai.com/browse/RT-12100但是,说您可以在 JavaFX 2.0 内部使用 swing 组件是不正确的: http://javafx-jira.kenai.com/-1

Also, I am experiencing issues where the JFileChooser dialog window does not reliably appear on top of the main application window.此外,我遇到了 JFileChooser 对话框 window 不能可靠地出现在主应用程序 window 顶部的问题。

http://javafx-jira.kenai.com/browse/RT-13839 covers adding a file chooser dialog to the FX 2.0 toolkit. http://javafx-jira.kenai.com/browse/RT-13839介绍了向 FX 2.0 工具包添加文件选择器对话框。

Just note, that there are no standard dialogs (information, warning, error) in JavaFX2.请注意,JavaFX2 中没有标准对话框(信息、警告、错误)。 BTW, why?顺便说一句,为什么? Using JavaFxDialog project for now.现在使用JavaFxDialog 项目

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM