I am new to this JavaFX business, as you probably can tell. This is a problem that I encountered while playing with the Canvas node. I have BorderPane as my root node, and I would like the canvas to occupy all the free space in the center of it. However, I have some problems implementing this exact behavior. Here is just what I tried:
public void start(Stage stage){
BorderPane root=new BorderPane();
Canvas canvas=new Canvas(250,250);
GraphicsContext gc=canvas.getGraphicsContext2D();
new AnimationTimer(){
@Override
public void handle(long l){
double width=canvas.getWidth(),height=canvas.getHeight();
gc.clearRect(0,0,width,height);
gc.strokeRect(0,0,width,height);
gc.strokeLine(0,0,width,height);
gc.strokeLine(0,height,width,0);
}
}.start();
root.setCenter(canvas);
root.setBottom(new Button("Placeholder"));
root.setTop(new Button("Placeholder"));
stage.setScene(new Scene(root));
stage.show();
}
, , , , . , , , ( ). BorderPane , , , ?