FULL PRODUCT VERSION :
owner@owner-VirtualBox:~$ java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
owner@owner-VirtualBox:~$
ADDITIONAL OS VERSION INFORMATION :
owner@owner-VirtualBox:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04 LTS
Release: 14.04
Codename: trusty
owner@owner-VirtualBox:~$
A DESCRIPTION OF THE PROBLEM :
After calling setMaximized it does not seem to report the new width and height of the stage immediately. This does work correctly on Windows but not currently on Linux. However this is not defined behavior on either regardless if it works on the former.
The idea is that one would like to know what the current or last maximized or restored dimensions of the window are before and after changing its maximized property.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a new stage with a button that changes the maximized property of the stage.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I was expecting the new restored width of the stage to be printed to the console, but instead the old maximized width was reported on Ubuntu. On windows it correctly reports the new restored width.
ACTUAL -
It reported the incorrect old maximized width of the window, even if I put it in a Platform.runLater(...) call.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package org.maximizeddelaytest.main;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class SetMaximizedDelay extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Maximized Delay Test");
Button btn = new Button();
btn.setText("Maximize/Restore");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println(primaryStage.getWidth());
primaryStage.setMaximized(!primaryStage.isMaximized());
// restored width reflected immediately on Windows but postponed on Ubuntu
System.out.println(primaryStage.getWidth());
}
});
StackPane root = new StackPane();
root.getChildren().add(btn);
primaryStage.setScene(new Scene(root, 300, 250));
primaryStage.show();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
I have not discovered a work around for this issue yet except to add a change listener to the width property, but that is not entirely correct. The better solution would be the addition of public members getMaximizedWidth/Height and getRestoredWidth/Height to the Stage/Window classes as can be done with JFrame in Swing.
SUPPORT :
YES