Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 面板的背景色_Java_Swing - Fatal编程技术网

Java 面板的背景色

Java 面板的背景色,java,swing,Java,Swing,我想改变我的课程背景。有一个JPanel。我想给它的背景上色。我使用的是frame.setBackground(Color.green),但它不能改变背景。你们能帮帮我吗?提前谢谢。试试这个 /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open t

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

试试这个

/*
 * 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);
    }

}
试试这个

/*
 * 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);
    }

}

谢谢。。这很好用,别忘了接受这个答案:)非常感谢。。很好,别忘了接受这个答案:)