简体   繁体   中英

JavaFx window to AWT window

I wrote a programm and I want to disable fullscreen on Mac, but standard apple library doesn't work. Because it needs an AWT window instead of my javafx one :

if(System.getProperty("os.name").toLowerCase().indexOf("mac") >= 0){
        com.apple.eawt.FullScreenUtilities.setWindowCanFullScreen(stage.getScene().getWindow(), false);
}

Can you explain how can I convert javafx window to awt window. If not can you recommend me another apple library for setWindowCanFullScreen, but with javafx

convert is a bad idea.

try something like this:

if(MAC) stage.setFullScreen(false);
stage.fullScreenProperty().addListener(new ChangeListener<Boolean>(){
        public void changed(ObservableValue<? extends Boolean> ov, Boolean oldv, Boolean newv){
            Platform.runLater(new Runnable(){
                public void run(){
                    if(MAC && oldv==false && newv==true)stage.setFullScreen(false);
                }
            });
        }
});

edit: A solution without a "small delay" stay unknown and interesting for us!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM