我无法更改 JApplet 的背景颜色。它总是灰色的。我在 NetBeans 工作。有人有什么建议吗?谢谢你。
解决方案感谢Крысa的回答,以下是问题的解决方案:必须使用getContentPane().setBackground(Color.WHITE);
@Override
public void init() {
/* Set the Nimbus look and feel */
//Look and feel setting code (optional)
/* Create and display the applet */
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
getContentPane().setBackground(Color.WHITE);
initComponents();
}
});
} catch (Exception ex) {}
}