Search code examples
javamacosjavafxmacos-sierra

How to make main javafx window still resizable coming back from full screen mode in MacOS


This issue is regarding JavaFX (jdk-9.0.1) on MacOS (I run Sierra). I'm developing a x-platform desktop app with a resizable main window primaryStage.setResizable(true), after I have clicked the little green button,see picture below, to go into full screen mode and then back again to normal mode the resizing of the window is no longer possible. How can I make it still resizable after coming back from full screen mode on MacOS?. It works on Windows and Linux but not on MacOS. Any help is much appreciated.

screenshot maximize button in macos

Edit 1: The issue is now reported and visible on bugs.java.com at the following url JDK-8191885


Solution

  • Thanks mipa! I discovered that it is even better to add a listener to the fullScreenProperty(), then you don't have to click into the title bar and move it a few pixels. The key was to do setResizable(false) followed by setResizable(true) though, thank you for finding that out. I will go with this workaround until the bug is fixed:

        primaryStage.fullScreenProperty().addListener((v,o,n) -> {
    
            if (!primaryStage.isFullScreen()) {
    
                primaryStage.setResizable(false);
                primaryStage.setResizable(true);
            }
        });