javafx Color parsing

Viewed 1830

Trying to let users select a custom Color scheme for their display.

User Input is turned into a javafx.scene.paint.Color c1. c1 is a valid Color. However, when i feed it into the setStyle method there is a parser error:

    System.out.println("c1 values: R" + c1.getRed()+ " G:"+ c1.getGreen()+" B:" + c1.getBlue());
    Button test = new Button("test");
    test.setStyle("-fx-background-color: " + c1);
    Scene login = new Scene(test,640,480);
    stage.setScene(login);
    stage.show();

c1 is a valid Color: "c1 values: R0.30588236451148987 Gb0.6745098233222961 B:1.0"

However there is a parsing error: "WARNING: CSS Error parsing '*{-fx-background-color: 0x4eacffff}: Unexpected token '0x' at [1,24]"

I suspect the Color (which returns doubles) is clashing with -fx-background-color which is expecting a HEX ( ? ) Am i using the tools wrong or do i need to unpack the doubles manually and recast to HEX?

1 Answers
Related