猿问

面板的背景颜色

/*

 * 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),但它不能改变背景。你们能帮帮我吗?提前致谢。


HUH函数
浏览 79回答 1
1回答

LEATH

尝试这个frame.getContentPane().setBackground(Color.GREEN);
随时随地看视频慕课网APP

相关分类

Java
我要回答