JavaFX fullscreen - zmiana rozmiaru elementów na podstawie rozmiaru ekranu
Czy jest jakiś sposób na zrobienie pełnoekranowego (i jeśli to możliwe również zmiany rozmiaru) zamiast zmiany układu wszystkiego (właściwie to, co robi, to przestawienie elementów, takich jak zmiana rozmiaru, ale na cały ekran), aby stworzyć rzeczywisty tryb pełnoekranowy? (podobnie jak gry, które zwykle zmieniają rozdzielczość ekranu), tak że przyciski i tekst rosną zgodnie z rozmiarem ekranu / okna
W jaki sposób mogę usunąć komunikat i efekt kliknięcia klawisza „esc”, aby wyjść z trybu pełnoekranowego?
EDYCJA: użyj tego sposobu, aby zmienić rozmiar
@Override public void start(Stage stage) throws Exception{
final int initWidth = 720; //initial width
final int initHeight = 1080; //initial height
final Pane root = new Pane(); //necessary evil
Pane controller = new CtrlMainMenu(); //initial view
controller.setPrefWidth(initWidth); //if not initialized
controller.setPrefHeight(initHeight); //if not initialized
root.getChildren().add(controller); //necessary evil
Scale scale = new Scale(1, 1, 0, 0);
scale.xProperty().bind(root.widthProperty().divide(initWidth)); //must match with the one in the controller
scale.yProperty().bind(root.heightProperty().divide(initHeight)); //must match with the one in the controller
root.getTransforms().add(scale);
final Scene scene = new Scene(root, initWidth, initHeight);
stage.setScene(scene);
stage.setResizable(true);
stage.show();
//add listener for the use of scene.setRoot()
scene.rootProperty().addListener(new ChangeListener<Parent>(){
@Override public void changed(ObservableValue<? extends Parent> arg0, Parent oldValue, Parent newValue){
scene.rootProperty().removeListener(this);
scene.setRoot(root);
((Region)newValue).setPrefWidth(initWidth); //make sure is a Region!
((Region)newValue).setPrefHeight(initHeight); //make sure is a Region!
root.getChildren().clear();
root.getChildren().add(newValue);
scene.rootProperty().addListener(this);
}
});
}