HeaderBar & Alert/Dialog/DialogPane

Michael Strauß michaelstrau2 at gmail.com
Wed Oct 22 00:07:27 UTC 2025


I think we can solve this by adding the Dialog.setHeaderBar(HeaderBar) method.

If the dialog is configured to use the EXTENDED stage style, then the
implementation will internally use a BorderPane root pane with the
HeaderBar on top, and the DialogPane at its center. In all other
cases, the DialogPane is used as the root pane. This is done
automatically and transparently, so developers won't need to resort to
the trick you mentioned (get the existing header node, nest it into a
BorderPane, and set the BorderPane as the new header node).

The limitations are the same as with Stage + HeaderBar: you won't get
title text or the title icon by default; if you want it, you'll need
to provide your own.

I've prepared a PR [0], maybe you can take a look at the API and see
if this solves your use cases.

- Michael

[0] https://github.com/openjdk/jfx/pull/1943


On Tue, Oct 21, 2025 at 12:04 AM Cormac Redmond <credmond at certak.com> wrote:
>
> Hi,
>
> I touched on this before, but I still think there are gaps that should be addressed with using HeaderBars and Alerts/Dialogs/DialogPanes.
>
> There's a bunch of logic in Alert/Dialog/DialogPane regarding headerText vs. headerNode precedence, graphic node placement, etc., which all depends on what is set and when, etc.
>
> To incorporate HeaderBar into Dialogs, the advice before was to "get" the existing header node, if it's there, and set it as the center of a new BorderPane and stick the HeaderBar as top, and set that BorderPane as the DialogPane's header, in order to use HeaderBar. But that only partially solves some problems, some of the time.
>
> If you use a HeaderBar for the purpose I do: to control the color (get rid of the ugly white bg) & to to save some precious space (i.e., get a menu system on the left + window icons on the right) *and* want a consistent look and feel across your application regarding popups, you must sacrifice all of this "standard" functionality of standard Alerts/Dialogs; or don't use HeaderBar for dialogs -- which looks unpolished and lacking.


More information about the openjfx-dev mailing list