On Sat, 14 Jun 2025 11:52:36 GMT, Marius Hanl <mh...@openjdk.org> wrote:
> 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`). I think that when you use an inheritance based system for controls, that you should always pick a starting point that does not yet have any unwanted behaviors or styles, instead of going for a move evolved starting point and then removing what you don't want. The latter is harder as future changes may add new behaviors that make sense for the control you branched off from but not for your use case. So if you don't want a Button that's clearly delineated for the user, that can have short cuts, can be hovered over, can be armed, disabled, highlighted, and participate as default or cancel action, then Button is not for you. So using Button to create a clickable Tab is not a good idea. The safest choice will be one of the container types as these don't have behaviors, nor do they have styles and skins. > 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). I think it was done to not have to de-evolve Button to make it into a Tab. Tab could be its own control, with its own styles and skins, but I think it is so integrated that it would rarely serve a purpose if it was available separately from TabPane. > 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. I didn't find any other instances where this is done. If a Hyperlink is not what is desired here, then I think it is a bad idea to use Hyperlink and try to second guess what its skin is doing in combination with the default style. Removing the hyperlink style means you'd need to style it yourself, which requires knowledge of the skin. So either: - It should not be a Hyperlink but something new, then create a new Control, or start from a Container type or any other type where you don't need to "remove" functionality or styling - It should be a Hyperlink, but just look a bit different, then add additional styles or replace its skin ------------- PR Comment: https://git.openjdk.org/jfx/pull/1779#issuecomment-3076515117