-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
8
-
OS X 10.9, Java 1.8.0ea b117
If you close an APPLICATION_MODAL stage in OS X it appears that all other application stages cycle to the front. If you have more than one stage open this causes a very noticeable flicker as the stage re-shuffle.
I can understand that closing a modal dialog should ensure its owner is now in the front but bring up all other stages seems excessive especially if it cannot be done without causing the flicker apparent on OS X.
Please run the following test case and then click on the button to open an app modal dialog. When you click on the close button to close the dialog you will see all the visible stages flicker to the front as they appear to re-shuffle.
*************************************************************************************
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.stage.Modality;
import javafx.stage.Stage;
public class ModalityTest extends Application {
@Override
public void start(final Stage primaryStage) throws Exception {
double x = 0;
double y = 0;
for (int i = 0; i < 4; i++) {
Stage stage = new Stage();
Text text = new Text("" + i);
text.setStyle("-fx-font-size: 3.0em;");
StackPane pane = new StackPane(text);
stage.setScene(new Scene(pane, 400, 300));
if ( x != 0 ) {
stage.setX(x + 50);
stage.setY(y + 50);
}
stage.show();
x = stage.getX();
y = stage.getY();
}
Button button = new Button("Dialog...");
button.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent event) {
final Stage dialog = new Stage();
Button b = new Button("Close");
b.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent event) {
dialog.close();
}
});
dialog.setScene(new Scene(new StackPane(b), 100, 50));
dialog.initModality(Modality.APPLICATION_MODAL);
dialog.initOwner(primaryStage);
dialog.setX(primaryStage.getX() + 100);
dialog.setY(primaryStage.getY() + 50);
dialog.showAndWait();
}
});
Text text = new Text("primary");
text.setStyle("-fx-font-size: 3.0em;");
VBox box = new VBox(20, text, button);
box.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
box.setAlignment(Pos.CENTER);
primaryStage.setScene(new Scene(new StackPane(box), 400, 300));
primaryStage.setX(x+ 50);
primaryStage.setY(y + 50);
primaryStage.show();
}
public static void main(String[] args) throws Exception {
launch(args);
}
}
I can understand that closing a modal dialog should ensure its owner is now in the front but bring up all other stages seems excessive especially if it cannot be done without causing the flicker apparent on OS X.
Please run the following test case and then click on the button to open an app modal dialog. When you click on the close button to close the dialog you will see all the visible stages flicker to the front as they appear to re-shuffle.
*************************************************************************************
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.stage.Modality;
import javafx.stage.Stage;
public class ModalityTest extends Application {
@Override
public void start(final Stage primaryStage) throws Exception {
double x = 0;
double y = 0;
for (int i = 0; i < 4; i++) {
Stage stage = new Stage();
Text text = new Text("" + i);
text.setStyle("-fx-font-size: 3.0em;");
StackPane pane = new StackPane(text);
stage.setScene(new Scene(pane, 400, 300));
if ( x != 0 ) {
stage.setX(x + 50);
stage.setY(y + 50);
}
stage.show();
x = stage.getX();
y = stage.getY();
}
Button button = new Button("Dialog...");
button.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent event) {
final Stage dialog = new Stage();
Button b = new Button("Close");
b.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent event) {
dialog.close();
}
});
dialog.setScene(new Scene(new StackPane(b), 100, 50));
dialog.initModality(Modality.APPLICATION_MODAL);
dialog.initOwner(primaryStage);
dialog.setX(primaryStage.getX() + 100);
dialog.setY(primaryStage.getY() + 50);
dialog.showAndWait();
}
});
Text text = new Text("primary");
text.setStyle("-fx-font-size: 3.0em;");
VBox box = new VBox(20, text, button);
box.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
box.setAlignment(Pos.CENTER);
primaryStage.setScene(new Scene(new StackPane(box), 400, 300));
primaryStage.setX(x+ 50);
primaryStage.setY(y + 50);
primaryStage.show();
}
public static void main(String[] args) throws Exception {
launch(args);
}
}