Reputation: 31
My color picker in javaFX returns something like 0x000000ff
. How to convert this to web colors, either rgb or hex?
Upvotes: 1
Views: 2137
Reputation: 159416
The answer to this for rgb values is right in the javadoc for ColorPicker:
final ColorPicker colorPicker = new ColorPicker();
colorPicker.setOnAction(new EventHandler() {
public void handle(Event t) {
Color c = colorPicker.getValue();
System.out.println("New Color's RGB = "+c.getRed()+" "+c.getGreen()+" "+c.getBlue());
}
});
Or you can get the color as a hex string for the above sample using:
String hexString = c.toString();
Upvotes: 2