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

}

I want to change my background of my program. There is a JPanel. I want to color it's background. I use frame.setBackground(Color.green), but it can't change the background. Could you please help me guys ? Thanks in advance.

Jacob G.
  • 28,856
  • 5
  • 62
  • 116
MD.FAHIM HOSSEN
  • 90
  • 2
  • 10

1 Answers1

2

Try this

frame.getContentPane().setBackground(Color.GREEN);
Reimeus
  • 158,255
  • 15
  • 216
  • 276