-
Bug
-
Resolution: Unresolved
-
P3
-
8u181
-
x86
-
os_x
A DESCRIPTION OF THE PROBLEM :
If a stage is set with "Always on Top" property true & have MAC's dock setting "minimize window in application icon" enabled, then the stage disappears after its iconified and deiconified.
While debugging I added event listener to stage, & after the stage disappeared I moved the mouse where the window was before disappearing & can see mouse events been shown, hence it seems like the stage is there but not visible for some reason.
Then I tried Jframe, & same issue exists in Jframe too. Stumbled upon a already existing bug report for this, but that was closed as they thought its MAC version issue, but its NOT it happens on most MAC versions if the dock configuration is enabled as mentioned above.
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8192788
People can fix this kind of issues themselves if you can give event listener for all three buttons of window i.e close, minimize & maximize AND listener for dock icon click event. Also if we can define priority of listener, which should run first and which should run later can give good control over application.
Example : here I could have removed Always on top before minimize begins
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Set Always on Top property true for your stage.
2. Enable Dock setting "minimize window in application icon"
3. Run application.
4. Minimize/Iconify your application.
5. Click on your app icon in dock to launch your app.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Window should appear.
ACTUAL -
Window appears for a split second and then disappears forever.
---------- BEGIN SOURCE ----------
package javafxbugreport;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventDispatchChain;
import javafx.event.EventDispatcher;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class JavaFXBugReport extends Application {
static Stage primaryStage;
@Override
public void start(Stage primaryStage) {
this.primaryStage=primaryStage;
Button btn = new Button();
btn.setText("Say 'Hello World'");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Hello World!");
}
});
StackPane root = new StackPane();
root.getChildren().add(btn);
Scene scene = new Scene(root, 300, 250);
primaryStage.setAlwaysOnTop(true);
//Added event listener for debugging
primaryStage.setEventDispatcher(new EventDispatcher() {
final EventDispatcher originalEventDispatcher = primaryStage.getEventDispatcher();
@Override
public Event dispatchEvent(Event event, EventDispatchChain tail) {
System.out.println("Event : " + event);
return originalEventDispatcher.dispatchEvent(event, tail);
}
});
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
//Workaround fix for disappearing window in MAC OS, if the "minimize window in application icon" is enabled.
primaryStage.iconifiedProperty().addListener(new ChangeListener<Boolean>(){
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
if(oldValue.equals(newValue)){
if(!newValue){
Platform.runLater(new Runnable() {
@Override
public void run() {
primaryStage.hide();
primaryStage.show();
}
});
}
}
}
});
FREQUENCY : always
If a stage is set with "Always on Top" property true & have MAC's dock setting "minimize window in application icon" enabled, then the stage disappears after its iconified and deiconified.
While debugging I added event listener to stage, & after the stage disappeared I moved the mouse where the window was before disappearing & can see mouse events been shown, hence it seems like the stage is there but not visible for some reason.
Then I tried Jframe, & same issue exists in Jframe too. Stumbled upon a already existing bug report for this, but that was closed as they thought its MAC version issue, but its NOT it happens on most MAC versions if the dock configuration is enabled as mentioned above.
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8192788
People can fix this kind of issues themselves if you can give event listener for all three buttons of window i.e close, minimize & maximize AND listener for dock icon click event. Also if we can define priority of listener, which should run first and which should run later can give good control over application.
Example : here I could have removed Always on top before minimize begins
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Set Always on Top property true for your stage.
2. Enable Dock setting "minimize window in application icon"
3. Run application.
4. Minimize/Iconify your application.
5. Click on your app icon in dock to launch your app.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Window should appear.
ACTUAL -
Window appears for a split second and then disappears forever.
---------- BEGIN SOURCE ----------
package javafxbugreport;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventDispatchChain;
import javafx.event.EventDispatcher;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class JavaFXBugReport extends Application {
static Stage primaryStage;
@Override
public void start(Stage primaryStage) {
this.primaryStage=primaryStage;
Button btn = new Button();
btn.setText("Say 'Hello World'");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Hello World!");
}
});
StackPane root = new StackPane();
root.getChildren().add(btn);
Scene scene = new Scene(root, 300, 250);
primaryStage.setAlwaysOnTop(true);
//Added event listener for debugging
primaryStage.setEventDispatcher(new EventDispatcher() {
final EventDispatcher originalEventDispatcher = primaryStage.getEventDispatcher();
@Override
public Event dispatchEvent(Event event, EventDispatchChain tail) {
System.out.println("Event : " + event);
return originalEventDispatcher.dispatchEvent(event, tail);
}
});
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
//Workaround fix for disappearing window in MAC OS, if the "minimize window in application icon" is enabled.
primaryStage.iconifiedProperty().addListener(new ChangeListener<Boolean>(){
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
if(oldValue.equals(newValue)){
if(!newValue){
Platform.runLater(new Runnable() {
@Override
public void run() {
primaryStage.hide();
primaryStage.show();
}
});
}
}
}
});
FREQUENCY : always
- relates to
-
JDK-8192788 Always on top JFrame disappears after restoration from iconified and fullscreen states
-
- Closed
-