JDK-8365201 : Restoring the maximized state of a window makes it exceed the screen's bounds
  • Type: Bug
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: jfx21,jfx25
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: linux
  • CPU: x86_64
  • Submitted: 2025-08-07
  • Updated: 2025-08-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
System:
  Kernel: 6.8.0-71-generic arch: x86_64 bits: 64 compiler: gcc v: 13.3.0 clocksource: tsc
  Desktop: Cinnamon v: 6.4.8 tk: GTK v: 3.24.41 wm: Muffin v: 6.4.1 vt: 7 dm: LightDM v: 1.30.0
    Distro: Linux Mint 22.1 Xia base: Ubuntu 24.04 noble

  Monitor-1: HDMI-A-1 mapped: HDMI-1 pos: right model: HP V27ie G5 serial: <filter>
    res: 1920x1080 hz: 60 dpi: 82 size: 597x336mm (23.5x13.23") diag: 685mm (27") modes:
    max: 1920x1080 min: 720x400
  Monitor-2: eDP-1 pos: primary,left model: AU Optronics 0x61ed res: 1920x1080 hz: 60 dpi: 142
    size: 344x194mm (13.54x7.64") diag: 395mm (15.5") modes: 1920x1080

Java:
openjdk version "21.0.8" 2025-07-15 LTS
OpenJDK Runtime Environment (build 21.0.8+12-LTS)
OpenJDK 64-Bit Server VM (build 21.0.8+12-LTS, mixed mode, sharing)

A DESCRIPTION OF THE PROBLEM :
In my application, I store the main window state somewhere so that when the user restarts it I can restore the position, size as well as maximized state.
There seems to be an issue on Linux for systems that have more than one monitor. If the window is maximized on the second monitor (in my case it's 1920x1080), the app is restarted and the state restored, the window will exceed the monitor's bounds (in my case the saved height is 1112px) hiding the decorations and making it impossible to resize the app or close it.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Download the MRE at <dropbox link>
2) Run 'gradle run' or './gradlew run'
3) Move the window to the second monitor, maximize it and close
4) Re-run the app again
5) The window's decoration should not be visible anymore and the label's text should highlight the fact that the height exceeds the screen's limits



Comments
[~tsayao] Can you comment on this? It seems like it might be related to JDK-8354943, which is under review.
11-08-2025

Additional Information from submitter ================================== public class Test extends Application { private Stage stage; @Override public void start(Stage stage) throws IOException { this.stage = stage; restoreWindowState(); Label label = new Label(); label.textProperty().bind(Bindings.createStringBinding( () -> String.format(Locale.US, "Stage size: [%.2f x %.2f]%nMaximized: %b", stage.getWidth(), stage.getHeight(), stage.isMaximized()), stage.widthProperty(), stage.heightProperty())); Button exitBtn = new Button("Exit"); exitBtn.setOnAction(e -> Platform.exit()); StackPane.setMargin(exitBtn, new Insets(100.0, 0.0, 0.0, 0.0)); StackPane root = new StackPane(label, exitBtn); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); } @Override public void stop() throws IOException { Path file = Path.of(".", "window_persist.properties"); Files.writeString(file, String.format(Locale.US, """ window.x=%.2f window.y=%.2f window.w=%.2f window.h=%.2f window.maximized=%b """, stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight(), stage.isMaximized()), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); } private void restoreWindowState() throws IOException { Path file = Path.of(".", "window_persist.properties"); if (!Files.exists(file)) { System.err.println("No window settings found, skipping restore..."); return; } Properties props = new Properties(); props.load(new FileInputStream(file.toFile())); double x = Double.parseDouble(props.getProperty("window.x")); double y = Double.parseDouble(props.getProperty("window.y")); double w = Double.parseDouble(props.getProperty("window.w")); double h = Double.parseDouble(props.getProperty("window.h")); boolean maximized = Boolean.parseBoolean(props.getProperty("window.maximized")); ObservableList<Screen> screens = Screen.getScreensForRectangle(x, y, w, h); if (!screens.isEmpty()) { stage.setX(x); stage.setY(y); stage.setWidth(w); stage.setHeight(h); stage.setMaximized(maximized); } } } I tested the bug on another setup, same system but different secondary screen and layout. I set the external display as my main one (so the status bar is here and not on the laptop's screen). If I maximize the window on the external display it is restored correctly, but if I maximize it on the laptop's screen I can't see the window's decorations anymore upon restart.
11-08-2025

Requested the submitter to provide the reproducer directly. Use of external storage links that can change in future are not allowed.
11-08-2025