JavaFX 2: Preventing Other Steps from Stealing Focus from the Main Stage

I have a milestone and would like to create some additional milestones (Windows). They will look like palettes in Photoshop that control the main scene, but I want the functionality to have a title bar, resize and be able to drag them anywhere on multiple monitors (this is not the case with the Popup class).

However, I do not want these thefts of focus from the main window all the time, in fact they should never steal focus, it would be better if they all were in the foreground at the same time. Is there any way to do this? I tried requestFocus () at the main stage, but it doesn’t even work. The only thing I can think of right now is to implement a user control to display the title bar and create a popup, but that sounds like pain, thanks

+4
source share
1 answer

Yes, it should work with .requestFocus() .
But for some reason you have to do this twice:

 primaryStage.requestFocus(); //put focus from dialog to main window Platform.runLater(new Runnable() { @Override public void run() { //focus again??? only then it works :-( primaryStage.requestFocus(); //put focus from dialog to main window } }); 
0
source

Source: https://habr.com/ru/post/1442451/


All Articles