Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Target Text on JavaFX UI Controls Through CSS

DZone's Guide to

Target Text on JavaFX UI Controls Through CSS

· Java Zone
Free Resource

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.

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 );
}

Result:

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

Download Building Reactive Microservices in Java: Asynchronous and Event-Based Application Design. Brought to you in partnership with Red Hat

Topics:

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

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}