【发布时间】:2022-01-11 01:16:05
【问题描述】:
在我的JPanel 中,我将JLabel 的背景设置为不同的颜色。我可以看到“测试”这个词,它是蓝色的,但背景根本没有改变。我怎样才能让它显示出来?
this.setBackground(Color.white);
JLabel label = new JLabel("Test");
label.setForeground(Color.blue);
label.setBackground(Color.lightGray);
this.add(label);
【问题讨论】: