Over a million developers have joined DZone.

Target Text on JavaFX UI Controls Through CSS

· Java Zone

Discover how powerful static code analysis and ergonomic design make development not only productive but also an enjoyable experience, brought to you in partnership with JetBrains

Here’s a small post on how you can target text on UI controls through CSS.

Just do this:

<control> .text
    /* CSS targeting the text in the UI control */

To change the text appearance on any of the JavaFX controls.

Example (adding a drop shadow to the text on a button):

.myButton .text {
    -fx-effect: dropshadow( one-pass-box , rgba(100, 100, 100, 0.5) , 0, 0.0 , 0 , 1 );


I think this is a very nice way to style text on UI controls, one which is not available on regular “Web HTML CSS”.

Learn more about Kotlin, a new programming language designed to solve problems that software developers face every day brought to you in partnership with JetBrains.


Published at DZone with permission of Pedro Duque Vieira. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}