Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX 2.2 Stage always on top

I have a normal JFrame (one part of the app) and a second JavaFX window (I can't use a JFrame for the JavaFX stage). The problem is that the JavaFX window should always be on top of all other windows.

I have no idea how I should solve this problem! Any ideas?

like image 634
user1706051 Avatar asked Oct 10 '12 12:10

user1706051


1 Answers

I know this is a old thread, but things keep on changing. Coming to JDK 8u20 is a new method primaryStage.setAlwaysOnTop(true);

This would be the easiest way to make a stage always on top. For early access to 8u20 visit the website.

public class KeyholeDemo extends Application {
    @Override public void start(Stage primaryStage) {
        primaryStage.initStyle(StageStyle.TRANSPARENT);
        primaryStage.setAlwaysOnTop(true);

        // code omitted...
    }

    public static void main(String[] args) {
        launch(args);
    }
}

Sample code taken from this nice writeup

like image 136
dev009 Avatar answered Sep 27 '22 22:09

dev009