Probably bug: UI changes made while minimized, not reflected upon restore/maximize

Cormac Redmond credmond at certak.com
Wed Mar 12 00:18:32 UTC 2025


Hi all,

A user reported this on reddit:
https://www.reddit.com/r/JavaFX/comments/1j8ibpf/platformrunlater_not_updating_the_content_when/

I do feel this is a bug so I'm raising it here. Windows 11, JFX 23.0.2.

A quick summary is: if you change a Label while your app is minimized, for
example, the change does not get reflected when restored/maximised, unless
_something else_ triggers a redraw, such as a window resize, or a hover
over a button, etc.

The act of simply maximising the window does seem to trigger a redraw. I
think it should.

Here are two fairly self-explanatory Java classes to demonstrate the
problem (adapted from the reddit post).

Steps:

- Run MinimizeBugApp, observe label
- Run Client, hit enter and observe label change as expected
- Minimize app, and hit enter on Client one or more times (all triggering
label changes)
- Restore app, note Label incorrectly still *displays* the same value as
before the minimize, despite update(s)
- Re-size window to force a redraw, observe correct label value appears


public class MinimizeBugApp extends Application {

    public void start(Stage stage) {
        Label label = new Label("This should be modified when the signal is
received");

        StackPane stackPane = new StackPane();
        stackPane.getChildren().add(label);
        Scene scene = new Scene(stackPane, 500, 500);
        stage.setScene(scene);
        stage.show();

        new Thread(() -> {
            this.startServer(label);
        }).start();
    }

    void startServer(final Label label) {
        try (ServerSocket serverSocket = new ServerSocket(1590)) {
            while (true) {
                System.out.println("Waiting for connection...");
                serverSocket.accept();
                Platform.runLater(() -> {
                    System.out.println("Setting signal is received...");
                    label.setText("The signal is received " + new Date());

                    // This will print the correct text, always -- but the
texted isn't what is reflected if
                    // it's minimized and then maximized
                    System.out.println("Label text should be: " +
label.getText());
                });
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        launch();
    }
}


// Simple test to trigger something in a JavaFX app via a socket
public class Client {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        while (true) {
            try {
                System.out.print("Hit enter to create connection");
                scanner.nextLine();
                new Socket("localhost", 1590);
                System.out.println("Created connection");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}


Any thoughts? Is this by design for some reason, or a bug?



Kind Regards,

*Cormac Redmond*
Software Engineer, Certak Ltd.

e: credmond at certak.com | m: +353 (0) 86 268 2152 | w: www.certak.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20250312/886c0e89/attachment-0001.htm>


More information about the openjfx-dev mailing list