-
Bug
-
Resolution: Fixed
-
P3
-
jfx11, 8
-
x86_64
-
generic
ADDITIONAL SYSTEM INFORMATION :
macOS High Sierra 10.13.6
Java 1.8.0_181
A DESCRIPTION OF THE PROBLEM :
This happens when two or more JavaFX Windows are on screen.
Eg. assume we have Window 1, Window 2.
We show an Alert with Window 1 as it's owner.
When the Alert is dismissed, the focus incorrectly goes to Window 2, not Window 1 which was the owner of the Alert.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the supplied test program.
Click on the button.
Observe that focus goes to the wrong window.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Focus should go to the Window which is the owner of the Alert.
ACTUAL -
Focus goes to the window which isn't the owner of the Alert.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class HelloWorld extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(
Stage primaryStage)
{
System.out.println("JRE: " + "Platform: " + System.getProperty("java.version"));
createWindow1(primaryStage);
createWindow2(primaryStage);
}
private void createWindow1(
Stage stage)
{
stage.setTitle("Hello World!");
Button btn = new Button();
btn.setText("Show Alert");
btn.setOnAction(new EventHandler<ActionEvent>()
{
@Override
public void handle(ActionEvent event)
{
showAlert(stage);
}
});
StackPane root = new StackPane();
root.getChildren().add(btn);
stage.setScene(new Scene(root, 300, 250));
stage.show();
}
private void showAlert(
Stage primaryStage)
{
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.initOwner(primaryStage);
alert.show();
}
private void createWindow2(
Stage stage1)
{
Stage stage = new Stage();
stage.setX(stage1.getX() + 300);
stage.setY(stage1.getY());
stage.setTitle("Hello World!");
StackPane root = new StackPane();
stage.setScene(new Scene(root, 300, 250));
stage.show();
}
}
---------- END SOURCE ----------
FREQUENCY : always
macOS High Sierra 10.13.6
Java 1.8.0_181
A DESCRIPTION OF THE PROBLEM :
This happens when two or more JavaFX Windows are on screen.
Eg. assume we have Window 1, Window 2.
We show an Alert with Window 1 as it's owner.
When the Alert is dismissed, the focus incorrectly goes to Window 2, not Window 1 which was the owner of the Alert.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the supplied test program.
Click on the button.
Observe that focus goes to the wrong window.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Focus should go to the Window which is the owner of the Alert.
ACTUAL -
Focus goes to the window which isn't the owner of the Alert.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class HelloWorld extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(
Stage primaryStage)
{
System.out.println("JRE: " + "Platform: " + System.getProperty("java.version"));
createWindow1(primaryStage);
createWindow2(primaryStage);
}
private void createWindow1(
Stage stage)
{
stage.setTitle("Hello World!");
Button btn = new Button();
btn.setText("Show Alert");
btn.setOnAction(new EventHandler<ActionEvent>()
{
@Override
public void handle(ActionEvent event)
{
showAlert(stage);
}
});
StackPane root = new StackPane();
root.getChildren().add(btn);
stage.setScene(new Scene(root, 300, 250));
stage.show();
}
private void showAlert(
Stage primaryStage)
{
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.initOwner(primaryStage);
alert.show();
}
private void createWindow2(
Stage stage1)
{
Stage stage = new Stage();
stage.setX(stage1.getX() + 300);
stage.setY(stage1.getY());
stage.setTitle("Hello World!");
StackPane root = new StackPane();
stage.setScene(new Scene(root, 300, 250));
stage.show();
}
}
---------- END SOURCE ----------
FREQUENCY : always