How do I set the background color for a window?
Printable View
How do I set the background color for a window?
If your window is a JFrame, JDialog or JWindow you can try
If it is a Frame of Window you can tryCode:myFrame.getContentPane().setBackground(yourColor)
JOptionPanes take a little more work.Code:myRef.setBackground(color)
Little explanation on this.
You can do this in this way as well.
In this way, when you run the application, background color flashes and gone. That is because the frame made up of mane components involving. That's why we used a "Content Pane" in the hardwired code.Code:myFrame.setBackground(yourColor)
thank you.