The trouble with Skins

Tom Eugelink tbee at tbee.org
Thu Mar 26 17:27:26 UTC 2015


On 25-3-2015 00:23, Tomas Mikula wrote:
>
> I'm sure you could make it work this way, but 1) it is a lot of work
> and 2) it is very fragile. It will break when ListView internals
> change or when the ListView is loaded with a different skin on
> restart. So it's a matter of how badly John wants this done.
>
> Btw, "inspecting the node tree" seems like "break open the controls" to me.

Well, yes and no. This approach will single out only those nodes that need to be visually restored, cutting through any control, like ListView, like if they were not that. For example when they use a scrollbar internally. I expect this approach will be easier and less work than having to restore each and every control.

> I think it is OK to say that ListView does not support this; my more
> general question was how should one proceed when writing a custom
> control that supports some view-specific details and at the same time
> wants to have customizable (i.e. skinnable) look & feel.
>

I had similar concerns back when JFX 2.0 was released. Jonathan may remember the discussion; how does JavaFX enable something like Synthetica in Swing? But it in the end comes down to replacing the skins on the control and using CSS you can. I also use another trick for my custom Swing components: they borrow styling from other controls. For example, I often use JTable and then get the highlight color, etc from it, and use that so my custom component blends in automatically. In JFX this is done with CSS. So it hasn't gotten worse compared to swing. But it would be nice if, for example, the focus border was something that can be applied to a control by simply adding the class (e.g. "focused"). And that isn't the case, because the CSS needs node to attach to. Maybe something like decorators, that can apply themselves to a node, would be an approach.

Tom


More information about the openjfx-dev mailing list