【问题标题】:Background color of a panel [duplicate]面板的背景颜色 [重复]
【发布时间】:2019-09-07 20:41:32
【问题描述】:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package foodmeterproject;

import java.awt.Color;

/**
 *
 * @author al-sany
 */
public class FoodMeterProject {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        FirstFrame frame=new FirstFrame();

        frame.setVisible(true);
        frame.setBackground(Color.green);
    }

}

我想更改我的程序背景。有一个JPanel。我想给它的背景上色。我使用frame.setBackground(Color.green),但它不能改变背景。你们能帮帮我吗?提前致谢。

【问题讨论】:

    标签: java swing


    【解决方案1】:

    试试这个

    frame.getContentPane().setBackground(Color.GREEN);
    

    【讨论】:

    • 非常感谢.. 它有效
    • 太好了,别忘了接受这个答案:)
    猜你喜欢
    • 2017-11-30
    • 1970-01-01
    • 1970-01-01
    • 2015-06-06
    • 2015-09-06
    • 1970-01-01
    • 1970-01-01
    • 2011-01-30
    • 1970-01-01
    相关资源
    最近更新 更多