Skip to content
Advertisement

Is it possible to use Color Hex in JLabel like #02f7fc?

Is it possible to use Color hex in JLabel such as #02f7fc? I want to use A-F colors. Using label.setForeground(Color.(BLUE/RED/BLACK/…); is so boring.

Advertisement

Answer

The following should allow you to set the colour using hex with the use of the decode method.

label.setForeground(Color.decode("#FFFF00"));
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement