I do not understand how to add more than two css-parameters to the component.

I do this:

this.setStyle( "-fx-background-color: silver; " + "-fx-font-size: 14px; " ); 

The fact is that when you try to add a third one, a parser error occurs with the message that the allowed size is exceeded.

The project is here .

  • make a separate .css file and connect it to the scene - Andrew Bystrov
  • And how to connect a separate css - file and bind it to a class (or object?)? - faoxis
  • scene.getStylesheets (). add ('path_to_css.css'); - Andrew Bystrov

1 answer 1

There is a simple solution for any successor to Node. Hang styles immediately in the StringProperty object.

As an example:

 Pane root = new Pane(); root.styleProperty().setValue( "-fx-background-color: red; -fx-background-radius: 10px; -fx-border-color: green; -fx-border-radius: 10px; -fx-border-width: 10px;");