setOpaque(true) を true に設定する必要があります。そうしないと、背景がフォームに描画されません。true に設定されていない場合、そのピクセルの一部またはすべてをフォームに描画することを読んでいると思います。背景はデフォルトで透明ですが、少なくとも私には奇妙に思えますが、プログラミングの方法では、以下に示すように true に設定する必要があります。
JLabel lb = new JLabel("Test");
lb.setBackground(Color.red);
lb.setOpaque(true); <--This line of code must be set to true or otherwise the
JavaDocs から
setOpaque
public void setOpaque(boolean isOpaque)
If true the component paints every pixel within its bounds. Otherwise,
the component may not paint some or all of its pixels, allowing the underlying
pixels to show through.
The default value of this property is false for JComponent. However,
the default value for this property on most standard JComponent subclasses
(such as JButton and JTree) is look-and-feel dependent.
Parameters:
isOpaque - true if this component should be opaque
See Also:
isOpaque()