jbilander
jbilander

Reputation: 651

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

Upvotes: 1

Views: 718

Answers (3)

jbilander
jbilander

Reputation: 651

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);
        }
    });

Upvotes: 0

mipa
mipa

Reputation: 10650

As it is not even planned to fix this bug before Java 11, we probably have to live with it for quite some time. I therefore have tried to find some kind of workarround for it and here it is:

Add this or something similar to your code.

primaryStage.maximizedProperty().addListener((v,o,n) -> {
    primaryStage.setResizable(false);
    primaryStage.setResizable(true);
});

Once you have de-maximized your stage via the green button the only thing you still have to do manually is to click into the title bar of your stage and move it for a few pixels. After that the stage should be resizable with the mouse again as usual. Its a nasty hack but still better than having to live with this bug forever.

Upvotes: 1

mipa
mipa

Reputation: 10650

This looks like a bug in JavaFX. I can reproduce this behaviour with JDK9 and 10ea. It still seems to work though for the latest JDK8. I have not found any workarround yet. You should report this at http://bugreport.java.com/

Upvotes: 0

Related Questions