1

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 ?

AJJ
  • 3,570
  • 7
  • 43
  • 76

1 Answers1

2

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.

jewelsea
  • 150,031
  • 14
  • 366
  • 406
  • Thanks. I am trying to draw a work flow kind of graph with javafx, is there any graph frameworks supports javafx. So that i can create a work flow kind of graph on my javafx component. – AJJ Aug 22 '13 at 06:12
  • @Rock123 I'm not sure what you are thinking of, but I find `JavaFX`'s capabilities quite impressive respect to Swing. Check the samples (http://www.oracle.com/technetwork/java/javafx/samples/index.html). You could not need an external library. – Veronica Cornejo Aug 22 '13 at 17:26