Delali
Delali

Reputation: 908

How to apply styles to a group of Labels in javafx without css

I have a javaFx VBox named countVBox in which a append Labels on the click of a button. Now with css, I can do:

.countVBox .label {
  -fx-background-color: #0000ff;
}

I want to achieve the same effect - making the label's background colour blue after it is appended, but without using css. Please tell me if it's possible. Thanks. I am using javafx 2.2

Upvotes: 0

Views: 909

Answers (1)

jewelsea
jewelsea

Reputation: 159341

You can access the background of a region (such as a label), using the getBackground() API. Once you have a background, there are methods on the background which will allow you to manipulate it via code.

In most cases I'd recommend using CSS (in a stylesheet) over manipulating the region background in Java code.

See also:

Upvotes: 2

Related Questions