Khafaga
Khafaga

Reputation: 1547

Applying CSS on JavaFx TreeTableView fails

I'm trying to apply some CSS on JavaFx8 TreeTableView and when I run the application I get

Feb 04, 2015 9:13:24 AM com.sun.javafx.css.StyleManager loadStylesheetUnPrivileged
WARNING: Resource "font-size: 10px;" not found.

and here is the code I'm using:

private TreeItem<ZajelUser> root;
root = ...
TreeTableView<ZajelUser> treeTableView;
treeTableView = new TreeTableView<>(root);
treeTableView.getStylesheets().add("font-size: 10px;");
treeTableView.applyCss();

Upvotes: 0

Views: 578

Answers (1)

eckig
eckig

Reputation: 11134

So there are two mistakes here:

  1. If you want to apply CSS styles directly, use Node.setStyle. Otherwise create a CSS file, write the rules there and attach the stylesheet with treeTableView.getStylesheets().add("myStyles.css;");
  2. You should change font-size: 10px; to -fx-font-size: 10px;.

See the JavaFX CSS Reference Guide.

Upvotes: 2

Related Questions