Solved

frame.setBackground(Color c)

Posted on 1998-03-27
3
1,384 Views
Last Modified: 2008-02-01
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
Comment
Question by:sandbar
3 Comments
 
LVL 2

Expert Comment

by:mgk
ID: 1233811
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
 

Author Comment

by:sandbar
ID: 1233812
I don't know if it makes a difference but this is an application not applet. Anyway the
validate idea did't work.
0
 
LVL 1

Accepted Solution

by:
biged040597 earned 20 total points
ID: 1233813
Try adding the component *before* setting the background color,
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question