I'm new to JavaFX, I'm learning it. I tried to make a canvas object as a root to scene graph in the application. However, I'm not able to do it. I need to create a group or a pane object and add canvas to the one of them. I'm curious about why we are not able to assign a canvas object as a root node. Probably, I'm missing some major points.
The code I tried to compile is as follows;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.canvas.Canvas;
import javafx.scene.Parent;
import javafx.scene.Scene;
public class driver extends Application {
public static void main(String[] args) {
launch(args);
}
Canvas canvas;
@Override
public void start( Stage stage ) {
canvas = new Canvas(300, 300);
Scene scene = new Scene(canvas, 300, 300);
stage.setScene(scene);
stage.show();
}
}