将 swing 与 javaFX 集成
我正在使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 JavaFX 应用程序中使用 Swing 有局限性,应避免。
有两种方法可以解决您的问题:
创建一个包含 2 个部分的 Swing 应用程序:FileExplorer 和 JFXPanel,用于所有 JavaFX 内容。
请参阅http://docs.oracle.com/javafx/ 2.0/api/javafx/embed/swing/JFXPanel.html
使用 JavaFX TreeView 控件并自己用文件系统信息填充它。
Using Swing in JavaFX application has limitations and should be avoided.
There are two ways to solve your problem:
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
Use JavaFX TreeView control and populate it with filesystem info yourself.