#White screen caused by mxHierarchicalLayout in JavaFX

1 messages ยท Page 1 of 1 (latest)

wise hearthBOT
#

<@&987246487241105418> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question ๐Ÿค–. Maybe it helps! In any case, a human is on the way ๐Ÿ‘. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#

re inverted). So, I tried using the mxHierarchicalLayout to set the orientation of the graph. However, when I do that, I only get a white screen.

Here's my code:

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception{
        Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
        primaryStage.setTitle("Graph Layout");
        primaryStage.setScene(new Scene(root, 800, 600));

        mxGraph graph = new mxGraph();
        Object parent = graph.getDefaultParent();

        graph.getModel().beginUpdate();
        try {
            Object v1 = graph.insertVertex(parent, null, "Vertex 1", 20, 20, 80,
                    30);
            Object v2 = graph.insertVertex(parent, null, "Vertex 2", 240,
                    150, 80, 30);
            Object v3 = graph.insertVertex(parent, null, "Vertex 3", 140,
                    310, 80, 30);
            Object v4 = graph.insertVertex(parent,null,"Vertex4",500,
                    400 ,80 ,30);

            graph.insertEdge(parent,null,"Edge1",v1,v2);
            graph.insertEdge(parent,null,"Edge2",v2,v3);
            graph.insertEdge(parent,null,"Edge3",v3,v4);

            mxHierarchicalLayout layout = new mxHierarchicalLayout(graph);
            layout.execute(graph.getDefaultParent());

        } finally {
            graph.getModel().endUpdate();
        }

        mxGraphComponent component = new mxGraphComponent(graph);
        component.setConnectable(false);

        ((BorderPane)root).setCenter(component);

        primaryStage.show();
    }


    public static void main(String[] args) {
        launch(args);
    }
}

The issue seems to be with the mxHierarchicalLayout class. When I remove the layout.execute(graph.getDefaultParent()) line, the graph is displayed correctly (albeit inverted). But when I include that line, I only get a white screen.

Can someone please help me figure out what's going wrong here?

echo burrow
#

When I use SwingConstant.SOUTH

wise hearthBOT
#

Closed the thread.