将 swing 与 javaFX 集成

发布于 2024-12-20 11:36:03 字数 558 浏览 2 评论 0原文

我正在使用 javaFX 2.0 制作一个应用程序。我想添加 fileExplorer (位于 http://www .java-forums.org/blogs/duvanslabbert/92-​​java-file-explorer.html)假设文件资源管理器是 swing。

在主阶段,组根我无法添加文件资源管理器,因为它不是 javafx 节点

    FileExplorer fe = new FileExplorer(new File("D:/"));
    myVbox.getChildren().add(fe);

我收到此错误:

The method add(Node) in the type List<Node> is not applicable for the arguments (FileExplorer)

i'm making an application with javaFX 2.0. i wanted to add fileExplorer (found on http://www.java-forums.org/blogs/duvanslabbert/92-java-file-explorer.html) given that the file explorer is swing.

in the main stage , group root i cant add the file explorer as it's not a javafx node

    FileExplorer fe = new FileExplorer(new File("D:/"));
    myVbox.getChildren().add(fe);

i get this error :

The method add(Node) in the type List<Node> is not applicable for the arguments (FileExplorer)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟凡古楼 2024-12-27 11:36:03

在 JavaFX 应用程序中使用 Swing 有局限性,应避免。

有两种方法可以解决您的问题:

  1. 创建一个包含 2 个部分的 Swing 应用程序:FileExplorer 和 JFXPanel,用于所有 JavaFX 内容。
    请参阅http://docs.oracle.com/javafx/ 2.0/api/javafx/embed/swing/JFXPanel.html

  2. 使用 JavaFX TreeView 控件并自己用文件系统信息填充它。

Using Swing in JavaFX application has limitations and should be avoided.

There are two ways to solve your problem:

  1. Create a Swing application with 2 parts: FileExplorer and JFXPanel for all JavaFX content.
    See http://docs.oracle.com/javafx/2.0/api/javafx/embed/swing/JFXPanel.html

  2. Use JavaFX TreeView control and populate it with filesystem info yourself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文