RFR: 8267606: Style classes not always working
alessandro.parisi406 at gmail.com
Wed Sep 29 10:47:17 UTC 2021
> It would be very helpful if you could provide a minimum reproducable
> example. So really just the code which is necessary for all of us to
> reproduce it.
Oh wow, what happened on JBS, there should be the projects files attached,
did Praveen forget to upload them?
Do I re-send additional information? What should I do?
For now, here's the link to download the project: Google Drive
Explanation and info on how to test:
The project has changed a bit, now there's a third example and the JavaFX
version has been updated to 17.
All examples can be run by modifying the Launcher class.
CSS files are in the resources folder and loaded by a ResourceManager.
1) The first example is TableTest. The main files for this test are
TableViewSkin and TableView.css.
The table has a HBox which contains the columns, from the CSS the
bottom border is set to be 'lightgray'. The test is set up to succeed
initially. However, if you go in the skin class and switch the ID for a
style class, update the CSS file accordingly (.custom-table-view
.columns-container) you'll see that the bottom border is not styled anymore.
Both the second and third examples are about the userAgentStylesheet which
doesn't behave correctly.
2) Let's start with the NotificationsTest first. The main files are
MFXNotificationCenter, MFXNotificationCenterSkin and NotificationCenter.css.
The icon shown in the StackPane comes from the NotificationsCounter class
(inner class of the skin). The icon should be big and gray. The test is set
to succeed initially. Let's take a look at the MFXNotificationCenter class,
at the bottom you'll see that I commented the getUserAgentStylesheet()
method and instead of using that I added a this call
'getStylesheets().add(STYLESHEET);' in the initialize() method. If you
invert this (uncomment the user agent method and remove this call) you'll
notice that the icon is not styled anymore. Now let's check the skin class,
check lines 31-109-212. If you comment the latter one you'll see that the
icon is styled again. The other lines have no visible effect for this test
but in the real control I must add them too, otherwise not everything is
3) The last example is the ToggleTest. This shows the exact same issue
described above but the structure/control is simplier. The example is set
to fail initially. If you run it you can see that the label has a black
line underneath which would be normal but the issue is that in the
MFXRectangleToggleNode.css (at the bottom of the file) the lines are set to
be transparent, the background too. To make it work, go into the skin class
(MFXRectangleToggleNodeSkin) uncomment the indicated line and it will work.
Another workaround is like I did above, instad of using the user agent, add
the stylesheet with 'getStylesheets().add(STYLESHEET);'
More information about the openjfx-dev