/*
* 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)
,但不能更改背景。你能帮我吗?预先感谢。
答案 0 :(得分:1)
尝试一下
frame.getContentPane().setBackground(Color.GREEN);