4 Replies Latest reply: Mar 17, 2013 8:32 PM by KonradZuse RSS

    Set Always on Top Stage Javafx

      How to set always on top stage javafx?
      Help Me.
        • 1. Re: Set Always on Top Stage Javafx
          This is not currently possible as far as I know.

          The closest you can get is to set fullscreen to true, and perhaps make part of your application transparent -- you will have to wait until this is added as a feature.
          • 2. Re: Set Always on Top Stage Javafx
            • 3. Re: Set Always on Top Stage Javafx
              I actually found a "way around" this situation. I use transparency and a popup with a change listener to the focused property and then my window is "always on top". The only problem it's kinda like a hack and generates an exception. Here's the code:
              import br.com.vieirawebstudio.util.StageHandler;
              import sun.security.util.Resources;
              import javafx.application.Application;
              import javafx.beans.value.ChangeListener;
              import javafx.beans.value.ObservableValue;
              import javafx.fxml.FXMLLoader;
              import javafx.scene.Node;
              import javafx.scene.image.Image;
              import javafx.scene.layout.HBox;
              import javafx.scene.layout.StackPane;
              import javafx.scene.paint.Color;
              import javafx.scene.shape.Rectangle;
              import javafx.stage.Popup;
              import javafx.stage.PopupBuilder;
              import javafx.stage.Screen;
              import javafx.stage.Stage;
              public class MainWindow extends Application {
                   private static Stage primaryStage;
                   private static final double WIDTH = 600.0;
                   private static final double HEIGHT = 40.0;
                   private ChangeListener<Boolean> changeListener;
                   public MainWindow()
                        changeListener = new ChangeListener<Boolean>() {
                             public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) 
                   public void start(Stage stage) throws Exception 
                        primaryStage = StageHandler.getStage();
                        StackPane root = new StackPane();
                        Rectangle frame = new Rectangle(WIDTH,HEIGHT, Color.web("#000"));
                        HBox pane = FXMLLoader.load(getClass().getResource("/fxml/MainWindow.fxml"), Resources.getBundle("bundle.MainWindow"));
                        primaryStage.getIcons().add(new Image(getClass().getResource("/icons/logo.png").toString()));
                        primaryStage.setX((Screen.getPrimary().getVisualBounds().getWidth() - WIDTH)/2);
                        final Popup popup = getAlwaysOnTop(root);
                   public Popup getAlwaysOnTop(Node root)
                        Popup xmlWindow = PopupBuilder
                        return xmlWindow;
              • 4. Re: Set Always on Top Stage Javafx
                I found something here. http://snipplr.com/view/69423/javafx-always-on-top/

                As well as this topic, but I'm curious now if there is anything planned for 8 for always on top?