RFR: 8354795: DialogPane show details button wipes out base style class "hyperlink"
Michael Strauß
mstrauss at openjdk.org
Thu Apr 17 20:47:53 UTC 2025
On Wed, 16 Apr 2025 08:51:36 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:
> The "show details" hyperlink button in an alert dialog that has an expandable detail area wipes out its base style class by overwriting all styles. This means styling in modena.css that targets `.hyperlink` is no longer applied, like the default text fill colors.
>
> The culprit is this code in DialogPane:
>
> InvalidationListener expandedListener = o -> {
> final boolean isExpanded = isExpanded();
> detailsButton.setText(isExpanded ? lessText : moreText);
> detailsButton.getStyleClass().setAll("details-button", (isExpanded ? "less" : "more")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
> };
>
> Here it uses `setAll` to set styles, wiping out the default `.hyperlink` style from "Hyperlink detailsButton = new HyperLink()"
It seems a bit unusual to remove the default style class of a control. If you use a `Hyperlink` control, you also want the result to be hyperlinky and inherit all the hyperlinky styles. This is probably the reason why this control was used here in the first place.
If you don't want your control to be hyperlinky (and also not buttony), the cleaner solution would be to not use `Hyperlink`, but derive a new control from the look-less `ButtonBase` instead, which doesn't come with default styling.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1779#issuecomment-2813986302
More information about the openjfx-dev
mailing list