Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 春季的JavaFX画布_Spring_Canvas_Javafx - Fatal编程技术网

Spring 春季的JavaFX画布

Spring 春季的JavaFX画布,spring,canvas,javafx,Spring,Canvas,Javafx,如何在Spring应用程序中集成小型画布 类似于带有 帆布 按钮 标签 输入 然后在按钮上画圆圈或一条线, 但所有的一切仍在春天的争夺中 我找不到spring+fx的好例子 我有 public abstract class FXMLController implements InitializingBean, Initializable { ... @Override public void afterPropertiesSet() throws Exception { loa

如何在Spring应用程序中集成小型画布

类似于带有 帆布 按钮 标签 输入

然后在按钮上画圆圈或一条线, 但所有的一切仍在春天的争夺中

我找不到spring+fx的好例子

我有

public abstract class FXMLController
    implements InitializingBean, Initializable {
...

@Override
public void afterPropertiesSet() throws Exception {
    loadFXML();
}

protected final void loadFXML() throws IOException {
    try (InputStream fxmlStream = getClass().getResourceAsStream(fxmlFilePath)) {
        FXMLLoader loader = new FXMLLoader();
        loader.setController(this);

        this.view = (loader.load(fxmlStream));

    }
}

public Node getView() {
    return view;
}

但整个窗格被覆盖, 我只想将我的矩形添加到小画布中,并保留来自fxml的按钮

差不多 scene.getRoot().getChildren().add(r)

解决了这个问题

还有这个

编辑root是错误的方法 您需要gc=calcCanvas.getGraphicsContext2D();在initialize()方法中

public class DemoController
    extends FXMLController {
 ...
@FXML
public void drawCanvas() throws Exception{

        //Group root = new Group();
        Rectangle r = new Rectangle(25,25,25,25);
        r.setFill(Color.BLUE);
        root.getChildren().add(r);
        calcCanvas.getScene().setRoot(root);
}