JavaFx中的Jgraph [英] Jgraph in JavaFx

查看:294
本文介绍了JavaFx中的Jgraph的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在JavaFx 2.0中使用jgraphx?

Is it possible to use jgraphx with JavaFx 2.0?

我尝试使用下面的代码,但我无法将图形组件添加到JavaFx组件。

I have tried using the below code, but i could not add the graph component to the JavaFx component.

        mxGraph graph = new mxGraph();
        Object parent = graph.getDefaultParent();
        graph.getModel().beginUpdate();
        try {
            Object v1 = graph.insertVertex(parent, null, "Hello", 20, 20, 80,
                    30);
            Object v2 = graph.insertVertex(parent, null, "World!", 240, 150,
                    80, 30);
            graph.insertEdge(parent, null, "Edge", v1, v2);
        } finally {
            graph.getModel().endUpdate();
        }
        mxGraphComponent graphComponent = new mxGraphComponent(graph);
        TitledPane tPane = new TitledPane();
        tPane.setAnimated(false);
        tPane.setExpanded(false);
        tPane.setMaxWidth(1040);
        tPane.setText("Load Module " + i);
        tPane.setAnimated(true);
        tPane.setContent(graphComponent); // Error here. setContent() does not accept graph

我如何使用/添加jgraph到JavaFX组件?任何想法?

How can i use/add jgraph to the JavaFX component? Any ideas ?

推荐答案

jgraph是一个基于Swing的库。目前,Swing程序可以嵌入JavaFX组件,但JavaFX程序无法嵌入Swing组件。 Java 8将包含JavaFX程序嵌入Swing组件的能力。这肯定会加速Java FX的采用。但对于JavaFX 2.x,它可能是其中之一。

jgraph is a Swing-based library. Currently Swing programs can embed JavaFX components, but JavaFX programs cannot embed Swing components. Java 8 will include an ability for JavaFX programs to embed Swing components. This will accelerate Java FX's adoption for sure. But for JavaFX 2.x, it's either one or the other.

这篇关于JavaFx中的Jgraph的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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