-
Bug
-
Resolution: Fixed
-
P3
-
jfx17
-
b01
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8289267 | jfx17.0.4 | Johan Vos | P3 | Resolved | Fixed |
ADDITIONAL SYSTEM INFORMATION :
Oracle Java 11
OpenJFX 17.0.2
Tested on Windows 10 and Ubuntu 20.04
A DESCRIPTION OF THE PROBLEM :
After JFX17, Modal behavior has changed producing a bad user experience, it returns to the "wrong previous stage".
If you have a button into a stage and call a Alert, after close the alert JFX is "calling" other stage and bringing it to front.
The "other stage" is the latest stage created (the wrong one, and not the one that called the button click)
Until JFX 16 the behavior was the expected one.
REGRESSION : Last worked in version 16
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Run the sample code using JavaFX 17 (17.0.2)
2) On the "Main Window" Click on button "One".
3) It'll open a new Stage/Window called "Window One".
4) On the "Main Window" Click on button "Two".
5) It'll open a new Stage/Window called "Window Two" (the latest stage created)
6) On the "Window One" Click on button "Click here".
7) It'll open a Alert Dialog.
8) On the Alert Dialog click on Close Button.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The focus should return to the "Window One", this "Window One" was the stage that called the Alert Dialog.
Info: It works fine when I tested with JavaFX 16.
ACTUAL -
The focus is returning to the "Window Two", this "Window Two" wasn't the stage that called the Alert Dialog.
---------- BEGIN SOURCE ----------
package com.jardelnovaes.jfx.tests;
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.SceneAntialiasing;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Region;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.Window;
public class App extends Application {
public static void main(String[] args) {
launch();
}
@Override
public void start(Stage stage) {
var panel = new HBox();
var label = new Label("Main Window");
panel.getChildren().addAll(label, createButton("One"), createButton("Two"));
panel.setAlignment(Pos.CENTER);
var scene = new Scene(panel, 200, 200);
stage.setScene(scene);
stage.show();
}
private Button createButton(final String id) {
var button = new Button(id);
button.setOnAction(e -> new WindowChild(null, "Window " + id).showAndWait());
return button;
}
class WindowChild extends Stage {
public WindowChild(Window owner, final String title) {
var panel = new HBox();
panel.setAlignment(Pos.CENTER);
var scene = new Scene(panel, 250, 250, false, SceneAntialiasing.DISABLED);
this.setScene(scene);
if (owner != null) {
this.initOwner(owner);
}
panel.getChildren().add(getContent(title));
}
private Pane getContent(final String title) {
var panel = new HBox();
var label = new Label(title);
var button = new Button("Click here");
button.setOnAction(e -> {
var alert = new Alert(Alert.AlertType.ERROR, "An error message", ButtonType.CLOSE);
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.initModality(Modality.APPLICATION_MODAL);
alert.showAndWait();
});
panel.getChildren().addAll(label, button);
panel.setAlignment(Pos.CENTER);
return panel;
}
}
}
---------- END SOURCE ----------
FREQUENCY : always
Oracle Java 11
OpenJFX 17.0.2
Tested on Windows 10 and Ubuntu 20.04
A DESCRIPTION OF THE PROBLEM :
After JFX17, Modal behavior has changed producing a bad user experience, it returns to the "wrong previous stage".
If you have a button into a stage and call a Alert, after close the alert JFX is "calling" other stage and bringing it to front.
The "other stage" is the latest stage created (the wrong one, and not the one that called the button click)
Until JFX 16 the behavior was the expected one.
REGRESSION : Last worked in version 16
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Run the sample code using JavaFX 17 (17.0.2)
2) On the "Main Window" Click on button "One".
3) It'll open a new Stage/Window called "Window One".
4) On the "Main Window" Click on button "Two".
5) It'll open a new Stage/Window called "Window Two" (the latest stage created)
6) On the "Window One" Click on button "Click here".
7) It'll open a Alert Dialog.
8) On the Alert Dialog click on Close Button.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The focus should return to the "Window One", this "Window One" was the stage that called the Alert Dialog.
Info: It works fine when I tested with JavaFX 16.
ACTUAL -
The focus is returning to the "Window Two", this "Window Two" wasn't the stage that called the Alert Dialog.
---------- BEGIN SOURCE ----------
package com.jardelnovaes.jfx.tests;
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.SceneAntialiasing;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Region;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.Window;
public class App extends Application {
public static void main(String[] args) {
launch();
}
@Override
public void start(Stage stage) {
var panel = new HBox();
var label = new Label("Main Window");
panel.getChildren().addAll(label, createButton("One"), createButton("Two"));
panel.setAlignment(Pos.CENTER);
var scene = new Scene(panel, 200, 200);
stage.setScene(scene);
stage.show();
}
private Button createButton(final String id) {
var button = new Button(id);
button.setOnAction(e -> new WindowChild(null, "Window " + id).showAndWait());
return button;
}
class WindowChild extends Stage {
public WindowChild(Window owner, final String title) {
var panel = new HBox();
panel.setAlignment(Pos.CENTER);
var scene = new Scene(panel, 250, 250, false, SceneAntialiasing.DISABLED);
this.setScene(scene);
if (owner != null) {
this.initOwner(owner);
}
panel.getChildren().add(getContent(title));
}
private Pane getContent(final String title) {
var panel = new HBox();
var label = new Label(title);
var button = new Button("Click here");
button.setOnAction(e -> {
var alert = new Alert(Alert.AlertType.ERROR, "An error message", ButtonType.CLOSE);
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.initModality(Modality.APPLICATION_MODAL);
alert.showAndWait();
});
panel.getChildren().addAll(label, button);
panel.setAlignment(Pos.CENTER);
return panel;
}
}
}
---------- END SOURCE ----------
FREQUENCY : always
- backported by
-
JDK-8289267 Modal behavior returns to wrong stage
- Resolved