Setting background color for a JFrame

awt, graphics, java, swing

Solution

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

Example:

myJFrame.getContentPane().setBackground( desiredColor );

Problem

How do you set the background color for a `JFrame`?

Original source