On Tue, 21 Oct 2025 23:54:55 GMT, Michael Strauß <[email protected]> wrote:

> Adds the `Dialog.headerBar` property, which allows developers to specify a 
> custom `HeaderBar` when the dialog uses the `EXTENDED` stage style. The 
> property is ignored for all other stage styles.

More strange behaviour, this time using Labels and setting a min height, leads 
to different behaviours...

<img width="619" height="633" alt="image" 
src="https://github.com/user-attachments/assets/9e767493-3f80-4ca9-b29c-cba9199b6dac";
 />


public class DialogBugDemoTwo extends Application {

    @Override
    public void start(Stage stage) {
        Button infoBtn = new Button("Show Two Alerts");
        infoBtn.setOnAction(e -> {
            showInfo(true, false, "with header, NO min height");
            showInfo(false, true, "NO header, with min height");
            showInfo(true, true, "with header, with min height");
            showInfo(false, false, "NO header, NO min height");
        });
        stage.setScene(new Scene(new VBox(10, infoBtn), 400, 300));
        stage.show();
    }

    private void showInfo(boolean withHeaderBar, boolean setMinHeight, String 
desc) {
        Alert alert = new Alert(AlertType.INFORMATION);
        alert.setHeaderText(null);
        alert.initModality(Modality.NONE);

        // Set preferred width causing the issue to manifest, no issue without 
it
        alert.getDialogPane().setPrefWidth(600); // Comment out and bug goes 
away

        alert.getDialogPane().setContent(createVbox(desc));

        if (setMinHeight) {
            alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
        }
        // Display issues only occur when HeaderBar is set
        if (withHeaderBar) {
            alert.setHeaderBar(new HeaderBar());
            alert.initStyle(StageStyle.EXTENDED);
        }

        alert.show();
    }

    private VBox createVbox(String desc) {
        final Label lbl1 = new Label(desc + ".... 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 
0; end of first Label.");
        lbl1.setWrapText(true);

        final Label lbl2 = new Label("1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
2 3 4 5 6 7 8 9 0; end of second Label.");
        lbl2.setWrapText(true);

        return new VBox(lbl1, new VBox(lbl2));
    }

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

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1943#issuecomment-3438861997

Reply via email to