RFR: 8354795: DialogPane show details button wipes out base style class "hyperlink"

Marius Hanl mhanl at openjdk.org
Sat Jun 14 11:55:33 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()"

I think wiping default style classes should not be done.

Maybe somewhat related and only my understanding:
There are quite some places in JavaFX Controls where e.g. a `StackPane` is used to somewhat mimic a `Control` (often a `Button`).

Example: The `TitleRegion` is a `StackPane`, but behaves like a `Button`. This may was done to avoid focus issues, but I can also imagine that this was done to not wipe default style classes / break styling. 
In the example the `title` style class is set there (If it would be a `Button`, it would be wiped as well there, which might be expected or not for some developers).

So to come back, this looks to be the only place where this is done, right? I agree that is should keep the `hyperlink` style class and not wipe them. Or something else must be used, which is probably not feasable.

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

PR Comment: https://git.openjdk.org/jfx/pull/1779#issuecomment-2972657648


More information about the openjfx-dev mailing list