HeaderBar (preview) clipped out of window during resize

Cormac Redmond credmond at certak.com
Tue Jun 24 17:08:36 UTC 2025


Hi,

I have found an "issue" (open to debate) where the HeaderBar's nodes are
pushed out of view. This issue is easily reproduced by wrapping a scene's
root node in a StackPane (something that is common for ControlsFx to do, as
an example, & without the developer even being aware -- I suspect other
libraries do something similar).

Although the observed behaviour is arguably logically correct, I think this
should be preventable (e.g, HeaderBar has/gets special meaning/treatment).

Example: run the below code, vertically resize the window, notice the
header/title bar stays in place. Click the button and resize the window
again and notice the title bar clips off the screen simply by making minor
vertical size adjustments. The window icons remain present.

public class DisappearingHeaderBug extends Application {

    @Override
    public void start(Stage primaryStage) {
        BorderPane root = new BorderPane();
        Button button = new Button("Click for \"bug()\"!");
        button.setOnAction(_ -> bug(root));

        final VBox vbox = new VBox(120, new Label("Something above..."),
button, new Label("Something below..."));
        root.setCenter(vbox);
        root.setTop(getHeaderBar());
         // root.setTop(new Label("!!! Label !!!")); // This is fine, though

        primaryStage.initStyle(StageStyle.EXTENDED);
        primaryStage.setScene(new Scene(root, 300, 500));
        primaryStage.show();
    }

    // Wrapping the root node in a stackpane is common
    private void bug(Pane root) {
        StackPane stackPane = new StackPane();
        root.getScene().setRoot(stackPane);
        stackPane.getChildren().addFirst(root);
    }

    private HeaderBar getHeaderBar() {
        HeaderBar headerBar = new HeaderBar();
        headerBar.setCenter(new Label(" --- HeaderBar ---"));
        headerBar.setLeading(new Label("L"));
        return headerBar;
    }

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

Sample video:
https://github.com/user-attachments/assets/93a320a5-0010-4941-a2a4-9e0e65cbd57d

I am using this latest HeaderBar/EXTENDED code, from this separate PR:
https://github.com/openjdk/jfx/pull/1831

The above issue also occurs simply by using ControlsFx's input field
validation, because, unbeknownst to the developer, ControlsFx ultimately
wraps the scene's root node in a DecorationPane (which is a StackPane).

I feel like HeaderBar + EXTENDED should somehow be given special treatment
to remain static and visible and not susceptible to breaking.

I do not know if I'd consider this as "bug" or not -- or if there's an
easy fix or not -- but it would prevent the usefulness of HeaderBar &
EXTENDED if there's no way to overcome it.



Kind Regards,
Cormac
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20250624/4e727453/attachment-0001.htm>


More information about the openjfx-dev mailing list