【问题标题】:Java - Japplet can not changebackground colorJava - 小程序无法更改背景颜色
【发布时间】:2011-12-02 14:11:40
【问题描述】:

我无法更改 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) {}

}

【问题讨论】:

    标签: java netbeans japplet


    【解决方案1】:

    您需要设置JApplet内容窗格的背景。

    【讨论】:

    • 非常非常非常感谢。感谢您的回答,我现在想通了。 getContentPane().setBackground(Color.WHITE);这应该在:JApplet 的 public void init()
    猜你喜欢
    • 1970-01-01
    • 2010-11-12
    • 2020-11-11
    • 1970-01-01
    • 2015-12-06
    • 2013-03-14
    • 2016-10-04
    • 2014-09-25
    • 1970-01-01
    相关资源
    最近更新 更多