Create color from web value : Color « JavaFX « Java






Create color from web value

 

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

public class Main extends Application {
  public static void main(String[] args) {
    launch(args);
  }

  @Override
  public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Label Sample");
    stage.setWidth(400);
    stage.setHeight(180);

    HBox hbox = new HBox();

    Label label1 = new Label("Search");
    label1.setTextFill(Color.web("#0076a3"));

     hbox.setSpacing(10);
    hbox.getChildren().add((label1));
    ((Group) scene.getRoot()).getChildren().add(hbox);

    stage.setScene(scene);
    stage.show();
  }
}

   
  








Related examples in the same category

1.Create Color from R G B value
2.Color.DARKBLUE
3.Color.TRANSPARENT
4.Set Rectangle Stroke to Color.BLACK
5.Names for JavaFX Standard Colors
6.Using Color constant
7.standard constructor, use 0->1.0 values, explicit alpha of 1.0
8.use 0->1.0 values. implicit alpha of 1.0
9.use 0->1.0 values, explicit alpha of 1.0
10.use 0->255 integers, implict alpha of 1.0
11.use 0->255 integers, explict alpha of 1.0
12.hue = 270, saturation & value = 1.0. inplict alpha of 1.0
13.hue = 270, saturation & value = 1.0, explict alpha of 1.0
14.blue as a hex web value, explict alpha
15.blue as a hex web value, implict alpha
16.Color as hex web value