Solved

frame.setBackground(Color c)

Posted on 1998-03-27
3
1,361 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
Comment Utility
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
Comment Utility
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
Comment Utility
Try adding the component *before* setting the background color,
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
scoreUp challenge 14 47
changeXy challenge 13 56
wordappend challenge 8 84
Groovy:unable to resolve class error 2 28
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now