Traditionally the background color of JLable is transparent, we can change it by using following code:

JPanel panel = new JPanel();
JLabel label = new JLabel("JLabel Demo");
label.setOpaque(true);
label.setForeground(Color.blue);
label.setBackground(Color.lightGray);
panel .add(label);

Code label.setOpaque(true) is required to paint the background color of JLabel.