Search code examples
javajcolorchooser

how to get the color in rgb to put it in the MySQL database JColorChooser


How can I get the color of the JColorChooser in rgb so I can save it to MySQL and use it to my Label when I want to use it?

My current doesnt give the specific number instead it gives me the output of

java.awt.Color[r=102,g=204,b=0]

Is there a way of getting just the rga number?

class GetColorChooser implements ChangeListener{

public void stateChanged(ChangeEvent e) {
    String lol = jccChooser.getColor().toString();
    System.out.print(lol);
}
}

Solution

  • Use Color#getRGB

    int rgbColor = jccChooser.getColor().getRGB();