Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default JavaFX-CSS

Tags:

css

fxml

javafx-8

Is there any way to see the applied CSS-Rules for JavaFX-Elements? Or there is a published reference with the default CSS-Rules available?

I would like, for example , to know the color of Toolbar's border.

like image 761
Gundon Avatar asked Aug 12 '12 14:08

Gundon


People also ask

Does JavaFX use CSS?

The default css is always applied to every JavaFX application. However, you can create one or more custom stylesheets of your own and add them to your application to override the default styles defined by JavaFX.

How do I add CSS to Scene Builder?

In Scene Builder, you can simulate the attachment of a style sheet to an application Scene by selecting Preview, then Scene Style Sheets, and finally selecting Add a Style Sheet or Open a Style Sheet option. This Preview command is useful when the ”root” style class is defined in the style sheet.


5 Answers

The CSS file is located in javafxrt.jar at jfxrt.jar!/com/sun/javafx/scene/control/skin/caspian/caspian.css .

Unfortunately, there is no API access to the CSS styles of an element as of now, though that is apparently being discussed for JavaFX 2.2.

like image 68
sarcan Avatar answered Oct 13 '22 07:10

sarcan


Here is the extracted caspian.css on pastebin - http://pastebin.com/0PebD9nR

like image 27
beardedlinuxgeek Avatar answered Oct 13 '22 06:10

beardedlinuxgeek


Modena theme

With JavaFX 8 the default CSS is a new theme called Modena. See announcement with screenshots.

See the latest versions on the OpenJFX site at GitHub.

The modena.css for the build version Java8_91 can be found here:

https://gist.github.com/maxd/63691840fc372f22f470

If you search the css file in different JDK versions this is the way to go.

JDK below 10.0: $JAVA_HOME/jre/lib/ext/jfxrt.jar --> com/sun/javafx/scene/control/skin/modena.

JDK for 10.0 and higher: $JAVA_HOME/jmods/javafx.controls.jmod --> classes/com/sun/javafx/scene/control/skin/modena.

like image 37
NDY Avatar answered Oct 13 '22 06:10

NDY


From Skinning JavaFX Applications with CSS: Default Style Sheet,

The default style sheet for JavaFX applications is caspian.css, which is found in the JavaFX runtime JAR file, jfxrt.jar

and

Use the following command to extract the style sheet from the JAR file:

jar -xf jfxrt.jar com/sun/javafx/scene/control/skin/caspian/caspian.css

and then just use a css viewer.

like image 24
mre Avatar answered Oct 13 '22 07:10

mre


As for the end of 2019 the default modena.css can be looked at official jfx github repo:

https://github.com/openjdk/jfx/tree/master/modules/javafx.controls/src/main/resources/com/sun/javafx/scene/control/skin/modena

Or you can look inside Maven javafx-controls. For example in javafx-controls-13-win.jar go to /com/sun/javafx/scene/control/skin/modena/

like image 24
BeshEater Avatar answered Oct 13 '22 06:10

BeshEater