3

If I create a javafx dialog using the following method:

public static void showDialog(Event event) throws IOException {
    dialogStage = new Stage();
    GridPane grid = (GridPane) Start.createLoader().load(Start.class.getResource("file.fxml").openStream());
    dialogStage.setScene(new Scene(grid));
    dialogStage.setTitle("Title");
    dialogStage.initModality(Modality.WINDOW_MODAL);
    dialogStage.initOwner(((Node) event.getSource()).getScene().getWindow());
    dialogStage.showAndWait();
}

the ower window moves in case it is maximized. This also happens if I use:

Modality.APPLICATION_MODAL

It works if I combine:

dialogStage.initModality(Modality.WINDOW_MODAL);
dialogStage.initOwner(primaryStage.getOwner());

but in this case the owner window is not blocked. I want my dialog showing up on a maximized window without moving it. The maximized window should be blocked while the dialog is open. How can I do this?

Btw. I am using java 8 and javafx on linux.

Tanks!

user1713946
  • 83
  • 1
  • 5
  • What do you mean by `owner window moves in case it is maximized` ? I am not sure if its the case because of Linux, but I am sure in windows and Mac, `Modality.WINDOW_MODAL` will block the parent window. Please refer [here for more information](http://docs.oracle.com/javafx/2/api/javafx/stage/Stage.html) – ItachiUchiha Jul 02 '14 at 06:43
  • As shown in the first listing I use Modality.WINDOW_MODAL and it blocks the parent window as expected. There is no problem if the parent window doesn't use the whole screen size (not fullsize) but if it uses the whole screen size the parent window moves a bit on the screen (to the right and down) before showing the dialog. As the parent window stays the same size, part of the parent window moves out of the screen. – user1713946 Jul 02 '14 at 07:19
  • Well, I can't replicate the situation in my MAC. How are you resizing the parent window to use the whole screen ? If you are resizing it by setting the size, you may try `stage.setMaximized(true);` in your parentStage ! – ItachiUchiha Jul 02 '14 at 09:20
  • thanks for your efforts! The user sets the size of the window and even if I set maximized in the code it doesn't help. I'll try on windows OS later. It's probably a linux specific thing. – user1713946 Jul 02 '14 at 09:32
  • 2
    It definitly seems to be a linux specific problem because I can observe the same problem using the javafxSceneBuiler 2.0 under linux. Some dialogs causing the same behavior there. – user1713946 Jul 02 '14 at 09:40
  • If you find this as an issue in javafx, please file an issue in [javafx jira](https://javafx-jira.kenai.com/) – ItachiUchiha Jul 02 '14 at 10:09
  • issue still present – Allexj Aug 25 '22 at 11:16
  • here is the bug report: https://bugs.openjdk.org/browse/JDK-8255347 still not fixed – Allexj Aug 25 '22 at 13:53
  • my friend with Ubuntu 20.04 doesn't have this bug: https://stackoverflow.com/questions/73593523/why-doesnt-my-friend-have-this-bug-while-i-am – Allexj Sep 03 '22 at 15:45

0 Answers0