I'm trying to set JFrame frame a background color, but it is not working. What am I missing here? this is the code:
public class PingPong extends JPanel{
private static final long serialVersionUID = 1L;
Ball ball = new Ball(this);
Table table = new Table(this);
Player player = new Player(this);
PC pc = new PC(this);
@Override
public void paintComponent(Graphics g){
super.paintComponent(g);
table.paint(g);
ball.repaint(g);
player.repaint(g);
pc.repaint(g);
}
public static void main(String[] args){
/* Creating the frame */
JFrame frame = new JFrame();
frame.setTitle("Ping Pong!");
frame.setSize(600, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new PingPong());
frame.getContentPane().setBackground(Color.DARK_GRAY);
frame.setVisible(true);
}
}
It just won't change colors..