Hi JavaFXers,
I'm struggling with properly scaling a JavaX stage, I was hoping that this I'm just missing something simple, and someone can help me out.
This simple application shows what I mean:
public class ScaleTest extends Application {
@Override
public void start(Stage primaryStage) {
GridPane grid = new GridPane();
grid.setAlignment(Pos.CENTER);
grid.add(new Text("Hello"), 0, 0, 2, 1);
grid.setBorder(new Border(new BorderStroke(Color.RED,
BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT)));
Scene scene = new Scene(grid, 300, 275);
primaryStage.setScene(scene);
primaryStage.show();
grid.getTransforms().add(new Scale(0.8, 0.8, 0, 0));
}
}
What happens is that when setting up the scaling for the pane in the scene, it gets scaled withing the window, Resizing the window doesn't help, because the inner pane just updates it's size. So basically there is a dead space between the pane and the window. My expectation would be to be able the scale the layout, with keeping its behaviour to its container's outer bounds.
I hope I'm making sense, and someone can help me understanding how this should be done.
Thanks a lot!
Szabolcs