in my swing application i was able to get the value of JButton color in terms of Red green blue values and i have stored these values in three integers, how to convert RGB values into hexadecimal value.
example i need in these format "#0033fA"
in my swing application i was able to get the value of JButton color in terms of Red green blue values and i have stored these values in three integers, how to convert RGB values into hexadecimal value.
example i need in these format "#0033fA"
int r, g, b;
Color color = new Color();
String hex = Integer.toHexString(color.getRGB() & 0xffffff);
if (hex.length < 6) {
hex = "0" + hex;
}
hex = "#" + hex;
you can use String hex = String.format("#%02x%02x%02x", r, g, b);