Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX Dialog and Alert appear behind main stage in RedHat

I am making use of JavaFX's built in Alert and Dialog classes which work great in Windows and when running from Eclipse within Windows, but appear behind the parent window when running on my target hardware which is running RedHat 6. I have tried tweaking various things including:

  • primaryStage.initStyle(StageStyle.UNDECORATED);

  • primaryStage.setFullScreen(true);

  • alert.initOwner(primaryStage) and alert.initOwner(primaryStage.getOwner())

  • alert.initModality(Modality.WINDOW_MODAL) and alert.initModality(Modality.APPLICATION_MODAL)

  • alert.initStyle(StageStyle.***) with *** being all possible styles.

The only way I have been able to get the alerts and dialogs to remain on top is by calling alert.initStyle(StageStyle.UTILITY) however this creates a window with a cross button which I do not want. Ideally I would prefer a bordered window without additional buttons, or an undecorated window which I should then be able to style to achieve the bordered look.

I have read of similar issues in which using Windows doesn't work but Ubuntu does. I haven't been able to find any open issues or solutions in this case.

I am using Java 8 Update 77.

like image 464
Adam Britto Avatar asked Oct 21 '25 22:10

Adam Britto


1 Answers

I have experienced a similar problem: Alerts would show perfectly well in front of the primary stage in Windows 10, yet behind the stage when running the program on Ubuntu. alert.initOwner(primaryStage) actually solved the problem for me.

like image 196
Sven Schirmer Avatar answered Oct 24 '25 14:10

Sven Schirmer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!