Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set style color for a line in javafx?

Tags:

css

javafx

How to set style color for a line in javafx?

 public void setColor(String color) {
      for (int i = 0; i < 9; i++){ 
          //lines[i].setFill(Color.BLUE);
          //lines[i].setStyle("-fx-Background-color: yellow;");
          //lines[i].setStyle("-fx-color:"+ color);
         //setStyle("-fx-Foreground-color:"+ color);
      }

  }

All 4 comments do nothing the lines not colored.

I would be happy if you could help me.

like image 476
gal kogeman Avatar asked Apr 15 '15 19:04

gal kogeman


People also ask

How do I change the color of a shape in JavaFX?

You can apply colors to nodes in JavaFX using the setFill() and setStroke() methods. The setFill() method adds color to the surface area of the node whereas the setStroke() method applies color to the boundary of the node. Both methods accept an object of the javafx.

How do you change the color of a circle in JavaFX?

Applying Color to the NodessetFill(color); //Setting color to the stroke Color color = new Color. DARKSLATEBLUE circle. setStroke(color); In the above code block, we are using the static variables of the color class to create a color object.

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.


Video Answer


1 Answers

Use -fx-stroke for coloring lines (using CSS)

line.setStyle("-fx-stroke: red;");

Or call setStroke() for coloring lines (using Java API):

line.setStroke(Color.RED);
like image 70
ItachiUchiha Avatar answered Oct 03 '22 15:10

ItachiUchiha