Domanda

Is it possible to use jgraphx with JavaFx 2.0?

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

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

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top