The setBackground method in JLabel does not seem to be working. import java.awt.*; import javax.swing.*; public class LabelTest { public static void main(String args[]) { JFrame frame = new JFrame(); Label label = new Label("This works!"); JLabel jLabel = new JLabel("This does not!"); Container contentPane = frame.getContentPane(); FlowLayout flowLayout = new FlowLayout(); contentPane.setLayout(flowLayout); label.setForeground(Color.white); jLabel.setForeground(Color.white); label.setBackground(Color.green); jLabel.setBackground(Color.red); contentPane.add(label); contentPane.add(jLabel); frame.setSize(350, 250); frame.setVisible(true); } }
|