0
    JFrame frame = new JFrame("New Frame");
    frame.setSize(1000,750);
    frame.add(new myComponent());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    frame.setBackground(Color.pink);

When I run this, the background in the frame still appears as white and not pink. Why?

Blood Brother
  • 105
  • 1
  • 2
  • 7

1 Answers1

1

Try this

frame.getContentPane().setBackground(Color.PINK);
tim
  • 467
  • 5
  • 12
  • You can't do exactly what you're trying to do. Read the first answer in [this thread](http://stackoverflow.com/questions/11268357/why-wont-my-background-color-display-in-jframe). [This](https://docs.oracle.com/javase/tutorial/uiswing/components/toplevel.html) might be a good place to continue to. – DSlomer64 Apr 12 '15 at 22:13