JavaFX将区域嵌入到特定窗格中

时间:2015-08-10 08:17:15

标签: javafx region pane

我想在特定窗格中使用tesis-dynaware(https://github.com/tesis-dynaware/graph-editor/wiki/1.%20Getting%20Started)中的图形编辑器。

不幸的是,该模型是JavaFX Region。有没有办法将JavaFX区域嵌入拆分窗格? Scene Builder在Miscellaneous下提供了一个Region,但我无法用数据填充它。我知道没有指定某个地区以这种方式工作......

编辑: 这是代码,它不显示graphEditor。如果我把它直接放到场景中就可以了。

public class Flowcharteditor extends Application {


@FXML Pane pane = new Pane();


@Override
public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));

    GraphEditor graphEditor = new DefaultGraphEditor();
    GModel model = GraphFactory.eINSTANCE.createGModel();
    graphEditor.setModel(model);
    addNodes(model);

    Scene scene = new Scene(root);

    pane.getChildren().addAll(graphEditor.getView());

    stage.setScene(scene);
    stage.show();
}


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


private GNode createNode() {

GNode node = GraphFactory.eINSTANCE.createGNode();

GConnector input = GraphFactory.eINSTANCE.createGConnector();
GConnector output = GraphFactory.eINSTANCE.createGConnector();

input.setType("left-input");
output.setType("right-output");

node.getConnectors().add(input);
node.getConnectors().add(output);

return node;
}

private void addNodes(GModel model) {

GNode firstNode = createNode();
GNode secondNode = createNode();

firstNode.setX(150);
firstNode.setY(150);

secondNode.setX(400);
secondNode.setY(200);
secondNode.setWidth(200);
secondNode.setHeight(150);

Commands.addNode(model, firstNode);
Commands.addNode(model, secondNode);

}

}

1 个答案:

答案 0 :(得分:0)

Region是Node的子类。您可以像任何其他节点一样嵌入它。

根据您的链接文档,我。即

GraphEditor graphEditor = new DefaultGraphEditor();

Scene scene = new Scene(graphEditor.getView(), 800, 600);

你要做的就是

splitPane.getItems().add( graphEditor.getView());