Setting background color for a JFrame

Raji picture Raji · Jul 4, 2009 · Viewed 415.3k times · Source

Just how do you set the background color for a JFrame?

Answer

Brandon E Taylor picture Brandon E Taylor · Jul 4, 2009

Retrieve the content pane for the frame and use the setBackground() method inherited from Component to change the color.

Example:

myJFrame.getContentPane().setBackground( desiredColor );