Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

frame.setBackground(Color c)

Posted on 1998-03-27
3
Medium Priority
?
1,428 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 40 total points
ID: 1233813
Try adding the component *before* setting the background color,
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

885 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