Documentation / FAQ / The graph viewer

Why mouse interaction does not work on javafx ?

Most of the time, it’s because the elements are added in the same panel as the graph, and due to that, the view panel cannot get the right coordinates. You can easily prevent that by providing the graph its own panel:

FxViewer view = new FxViewer(graph, FxViewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
FxViewPanel panel = (FxViewPanel) view.addView(FxViewer.DEFAULT_VIEW_ID, new FxGraphRenderer());
StackPane graphPane = new StackPane();
graphPane.getChildren().addAll(panel); // prevent UI shift issues