javaswingjpanelsetbackgroundcolor-codes

how to add back ground color for swing components using color codes?


I want to add back ground color for my JPanel in java . Instead of using Color.RED in the setBackground function , I want to use color code like #FFF380 in the function. Is it possible to use these color codes in the function.


Solution

  • It's extremely simple:

    xy.setBackground(Color.decode("#6365ff"));