Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1432
  • Last Modified:

frame.setBackground(Color c)

I have a window with 4 frames. setBackground(Color c) for the window works OK. The background
between the frames is OK but I can't get the backgroung of the frames to work.
//**************************************************************************
    Color bgcolor = new Color(100, 100, 255);
    Color fgcolor = new Color(255, 255, 255);
        // Create a Panel to contain all the components along the
        // left hand side of the window.  Use a GridBagLayout for it.
        panel1 = new Panel();
        panel1.setLayout(gridbag);
        panel1.setBackground((Color) bgcolor);
No matter what I try the panel background stays gray.
0
sandbar
Asked:
sandbar
1 Solution
 
mgkCommented:
This might be an answer: try calling this.validate() after setting up the layout to ensure the paint() methods get called; I think your applet is staying the default grey because it's not being repainted.

Mark King
http://www.ampersand.net.au
0
 
sandbarAuthor Commented:
I don't know if it makes a difference but this is an application not applet. Anyway the
validate idea did't work.
0
 
biged040597Commented:
Try adding the component *before* setting the background color,
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now