Target text on JavaFX UI controls through CSS

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”.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s