If I open another JavaFX (modal) Stage
, and set its owner as the original Stage
, then the original Stage
can't be resized, using the windows drag widget on the bottom right hand corner of the window
I see this in Linux but don't own windows or MacOS so can't test it elsewhere...
here is a minimal example
import javafx.stage.*; import javafx.scene.*; import javafx.event.*; import javafx.application.*; import javafx.scene.layout.*; import javafx.scene.control.*; public class HelloWorld extends Application { static Stage newStage; @Override public void start(Stage primaryStage) { Button btn = new Button(); btn.setText("open window"); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { if (newStage==null) { Button newBtn = new Button("Close window"); newBtn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //newStage.hide(); // either or newStage.close(); } }); newStage = new Stage(); newStage.initModality(Modality.WINDOW_MODAL); newStage.initOwner(primaryStage); // BUG doing this, makes main window fixed size newStage.initStyle(StageStyle.DECORATED); StackPane newRoot = new StackPane(); newRoot.getChildren().add(newBtn); Scene newScene = new Scene(newRoot,200,160); newStage.setScene(newScene); } newStage.show(); } }); StackPane root = new StackPane(); root.getChildren().add(btn); Scene scene = new Scene(root, 300, 250); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } }