-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
7u25
-
windows 7
I have a strange behavior while closing an APPLICATION_MODAL window which have an owner (parent) window.
I was expected that its parent will remain on top of all other windows but instead others are brought to top without any Event.
Here is the sample code I used to reproduce this behavior, close the "Child" window and look how "free" windows behave.
package mypkg;
import javafx.application.Application;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageBuilder;
public class WinHierarchy extends Application {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
launch(WinHierarchy.class, args);
}
@Override
public void start(Stage primaryStage) throws Exception {
Stage stage = StageBuilder.create().title("Child").build();
primaryStage.setTitle("Parent");
stage.initOwner(primaryStage);
stage.initModality(Modality.APPLICATION_MODAL);
primaryStage.show();
// USED TO TRACK EVENTS
applyEventFilter(stage);
applyEventFilter(primaryStage);
buildFreeWindow(5);
stage.showAndWait();
}
private void buildFreeWindow(int count) {
for (int i = 0; i < count; i++) {
Stage free = StageBuilder.create().title("free").build();
applyEventFilter(free);
free.show();
}
}
private void applyEventFilter(Stage stage) {
stage.addEventFilter(Event.ANY, new EventHandler<Event>() {
@Override
public void handle(Event event) {
System.out.println(event);
}
});
}
}
I was expected that its parent will remain on top of all other windows but instead others are brought to top without any Event.
Here is the sample code I used to reproduce this behavior, close the "Child" window and look how "free" windows behave.
package mypkg;
import javafx.application.Application;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageBuilder;
public class WinHierarchy extends Application {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
launch(WinHierarchy.class, args);
}
@Override
public void start(Stage primaryStage) throws Exception {
Stage stage = StageBuilder.create().title("Child").build();
primaryStage.setTitle("Parent");
stage.initOwner(primaryStage);
stage.initModality(Modality.APPLICATION_MODAL);
primaryStage.show();
// USED TO TRACK EVENTS
applyEventFilter(stage);
applyEventFilter(primaryStage);
buildFreeWindow(5);
stage.showAndWait();
}
private void buildFreeWindow(int count) {
for (int i = 0; i < count; i++) {
Stage free = StageBuilder.create().title("free").build();
applyEventFilter(free);
free.show();
}
}
private void applyEventFilter(Stage stage) {
stage.addEventFilter(Event.ANY, new EventHandler<Event>() {
@Override
public void handle(Event event) {
System.out.println(event);
}
});
}
}