Search code examples
javaswingjinternalframe

How ca i set Background Color in my JInternalFrames?


I need to set the background color in my JInternalFrames. I couldn't.

JInternalFrame frm = new JInternalFrame(); frm.setBackground(Color.red);

This don't work.

You knows how can i do this?

Thanks You.


Solution

  • Swing windows (JFrame, JDialog ...) and internal frames use a "content pane" to hold child components. So you need to set the background of the content pane:

    internalFrame.getContentPane().setBackground( Color.RED );
    

    Read the section from the Swing tutorial on Top Level Container for more information.

    Keep a link to the Swing tutorial handy for all the Swing basics.