Skip to content

Conversation

@mstr2
Copy link
Collaborator

@mstr2 mstr2 commented Oct 14, 2025

The HeaderBar control currently has three areas: leading, center, and trailing. Additionally, there's leftSystemInset and rightSystemInset, which are not RTL adjusted. I've come to the understanding that there is no particularly good reason for this, because every time you would want to use this information for layout purposes, it should also be adjusted for RTL.

With this in mind, there are three changes for the HeaderBar control:

  1. Rename leading to left, and trailing to right, which aligns the terminology with BorderPane.
  2. Adjust leftSystemInset and rightSystemInset for RTL.
  3. Make leftSystemInset, rightSystemInset, and minSystemHeight attached properties for Stage.

With this change, the HeaderBar control is more semantically consistent and easier to use, and the renamed left and right areas now show its close relationship with BorderPane.

/csr
/reviewers 2


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires a CSR request matching fixVersion jfx26 to be approved (needs to be created)
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1936/head:pull/1936
$ git checkout pull/1936

Update a local copy of the PR:
$ git checkout pull/1936
$ git pull https://git.openjdk.org/jfx.git pull/1936/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1936

View PR using the GUI difftool:
$ git pr show -t 1936

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1936.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 14, 2025

👋 Welcome back mstrauss! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 14, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the csr Need approved CSR to integrate pull request label Oct 14, 2025
@openjdk
Copy link

openjdk bot commented Oct 14, 2025

@mstr2 has indicated that a compatibility and specification (CSR) request is needed for this pull request.

@mstr2 this pull request must refer to an issue in JBS to be able to link it to a CSR request. To refer this pull request to an issue in JBS, please update the title of this pull request to just the issue ID.

@openjdk
Copy link

openjdk bot commented Oct 14, 2025

@mstr2
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@mstr2 mstr2 changed the title Update HeaderBar API 8369836: Update HeaderBar API Oct 14, 2025
@openjdk openjdk bot added the rfr Ready for review label Oct 14, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 14, 2025

Webrevs

@mlbridge
Copy link

mlbridge bot commented Oct 14, 2025

Mailing list message from Andy Goryachev on openjfx-dev:

Can you clarify what you mean by "aligning with" BorderPane?

Does it mean we are trying to propagate somewhat misleading terminology that was used by the BorderPane (setLeft() in RTL mode results in the added node on the right side, so it should really be named something like setLeading() instead of setLeft()).

Thanks,
-andy

From: openjfx-dev <openjfx-dev-retn at openjdk.org> on behalf of Michael Strau? <mstrauss at openjdk.org>
Date: Tuesday, October 14, 2025 at 09:40
To: openjfx-dev at openjdk.org <openjfx-dev at openjdk.org>
Subject: RFR: 8369836: Update HeaderBar API

The `HeaderBar` control currently has three areas: `leading`, `center`, and `trailing`. Additionally, there's `leftSystemInset` and `rightSystemInset`, which are not RTL adjusted. I've come to the understanding that there is no particularly good reason for this, because every time you would want to use this information for layout purposes, it should also be adjusted for RTL.

With this in mind, there are two changes for the `HeaderBar` control:
1. Rename `leading` to `left`, and `trailing` to `right`, which aligns the terminology with `BorderPane`.
2. Adjust `leftSystemInset` and `rightSystemInset` for RTL.

With this change, the `HeaderBar` control is more semantically consistent and easier to use, and the renamed `left` and `right` areas now show its close relationship with `BorderPane`.

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

Commit messages:
- Update HeaderBar API

Changes: https://git.openjdk.org/jfx/pull/1936/files
Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1936&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8369836
Stats: 212 lines in 3 files changed: 14 ins; 56 del; 142 mod
Patch: https://git.openjdk.org/jfx/pull/1936.diff
Fetch: git fetch https://git.openjdk.org/jfx.git pull/1936/head:pull/1936

PR: https://git.openjdk.org/jfx/pull/1936
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20251014/cb6293e4/attachment-0001.htm>

@mlbridge
Copy link

mlbridge bot commented Oct 14, 2025

Mailing list message from Michael Strauß on openjfx-dev:

Yes, exactly. "Left" and "right" is used in several places in JavaFX
(BorderPane, AnchorPane, Insets) to effectively mean "leading" and
"trailing".
HeaderBar is different, because it uses "left", "right", as well as
"leading" and "trailing" with a different definition than the other
controls (leading and trailing are RTL adjusted, while left and right
are not).
My proposal is to just accept that "left" and "right" are JavaFX
terminology for RTL-adjusted leading and trailing areas.

On Tue, Oct 14, 2025 at 6:52?PM Andy Goryachev
<andy.goryachev at oracle.com> wrote:

Can you clarify what you mean by "aligning with" BorderPane?

Does it mean we are trying to propagate somewhat misleading terminology that was used by the BorderPane (setLeft() in RTL mode results in the added node on the right side, so it should really be named something like setLeading() instead of setLeft()).

Thanks,
-andy

@mlbridge
Copy link

mlbridge bot commented Oct 14, 2025

Mailing list message from Andy Goryachev on openjfx-dev:

I would rather clarify the incorrect labels in the existing components. We obviously cannot change setLeft() - perhaps we should add explanation to the corresponding javadoc explaining RTL behavior. I would like to avoid making the same mistake going forward.

-andy

From: Michael Strau? <michaelstrau2 at gmail.com>
Date: Tuesday, October 14, 2025 at 10:02
To: Andy Goryachev <andy.goryachev at oracle.com>
Cc: Michael Strau? <mstrauss at openjdk.org>, openjfx-dev at openjdk.org <openjfx-dev at openjdk.org>
Subject: [External] : Re: RFR: 8369836: Update HeaderBar API

Yes, exactly. "Left" and "right" is used in several places in JavaFX
(BorderPane, AnchorPane, Insets) to effectively mean "leading" and
"trailing".
HeaderBar is different, because it uses "left", "right", as well as
"leading" and "trailing" with a different definition than the other
controls (leading and trailing are RTL adjusted, while left and right
are not).
My proposal is to just accept that "left" and "right" are JavaFX
terminology for RTL-adjusted leading and trailing areas.

On Tue, Oct 14, 2025 at 6:52?PM Andy Goryachev
<andy.goryachev at oracle.com> wrote:

Can you clarify what you mean by "aligning with" BorderPane?

Does it mean we are trying to propagate somewhat misleading terminology that was used by the BorderPane (setLeft() in RTL mode results in the added node on the right side, so it should really be named something like setLeading() instead of setLeft()).

Thanks,
-andy

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20251014/46137efc/attachment-0001.htm>

@mlbridge
Copy link

mlbridge bot commented Oct 14, 2025

Mailing list message from Michael Strauß on openjfx-dev:

Considering that the "left" and "right" terminology is deeply
entrenched in JavaFX, I see no advantage in trying to fight it.
However, I agree that we should clearly define what left and right
means in the context of RTL layouts, which is a bit different from the
usual dictionary definition of left and right.

On Tue, Oct 14, 2025 at 7:08?PM Andy Goryachev
<andy.goryachev at oracle.com> wrote:

I would rather clarify the incorrect labels in the existing components. We obviously cannot change setLeft() - perhaps we should add explanation to the corresponding javadoc explaining RTL behavior. I would like to avoid making the same mistake going forward.

-andy

@kevinrushforth
Copy link
Member

Reviewers: @andy-goryachev-oracle @kevinrushforth

@kevinrushforth kevinrushforth self-requested a review October 15, 2025 17:13
@kevinrushforth
Copy link
Member

Considering that the "left" and "right" terminology is deeply entrenched in JavaFX, I see no advantage in trying to fight it. However, I agree that we should clearly define what left and right means in the context of RTL layouts, which is a bit different from the usual dictionary definition of left and right.

I think this is a good choice from a consistency point of view.

@mstr2
Copy link
Collaborator Author

mstr2 commented Oct 17, 2025

There's another thing that I think will improve the HeaderBarAPI:

The leftSystemInset, rightSystemInset, and minSystemHeight properties shouldn't be normal properties, but attached properties for Stage. If you think about it, these aren't really properties of HeaderBar, but properties of Stage that are used in the context of HeaderBar.

We already have an attached property of this kind: HeaderBar.getPrefButtonHeight(Stage). Having the other three properties defined similarly makes the API more consistent.

It should be noted that this will be the first instance of an observable attached property in JavaFX. So while regular attached properties have a getter/setter pair like this...

class HBox {
    static Insets getMargin(Node);
    static void setMargin(Node, Insets);
}

...an observable attached property will have an observable property getter:

class HeaderBar {
    static ReadOnlyObjectProperty<Dimension2D> leftSystemInsetProperty(Stage);
    static Dimension2D getLeftSystemInset(Stage);
}

The form of the property getter shouldn't be controversial, as it follows the existing getter/setter form for attached properties.

What needs to be clarified, however, is what getBean() and getName() should return for an attached observable property.
Since an attached property is a part of the object it is attached to, the getBean() method should return that object. In our example, this means HeaderBar.leftSystemInsetProperty(myStage).getBean() == myStage.

For the getName() method, the usual convention is to return the lowerCamelCase name of the property. However, since an attached property is not declared on the object's class to which it is attached, the name shouldn't claim that it is. I propose a naming convention of the form DeclaringType.myProperty, that is, the property name is qualified with the declaring type. In our example, the name of the property would be "HeaderBar.leftSystemInset" (instead of just "leftSystemInset").

Copy link
Member

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API changes look good. I left a couple inline comments and questions.

Your proposal to add attached Properties seems reasonable and natural. My only question is whether the property name should be prefixes with the fully-qualified class name rather than just the unqualified name.

* is an empty {@code Dimension2D}.
*
* @param stage the {@code Stage}
* @return the {@code leftSystemInset} property
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs @since 26 javadoc tag (for all new methods).

* in a right-to-left layout.
* The left area of the {@code HeaderBar}.
*
* @defaultValue {@code null}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs @since 26 javadoc tag here and all other renamed methods (if the method name or signature changes then it is a new method in 26).

Comment on lines +886 to +888
this.leftSystemInset = new ReadOnlyObjectWrapper<>(stage, "HeaderBar.leftSystemInset", EMPTY);
this.rightSystemInset = new ReadOnlyObjectWrapper<>(stage, "HeaderBar.rightSystemInset", EMPTY);
this.minSystemHeight = new ReadOnlyDoubleWrapper(stage, "HeaderBar.minSystemHeight");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the classname prefix in the property name be fully qualified? If it were, then a utility could find the corresponding method(s) from the bean using the convention that if a name contains a ., it is an attached property with the bean being an argument to the named (static) method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

csr Need approved CSR to integrate pull request rfr Ready for review

Development

Successfully merging this pull request may close these issues.

2 participants