CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 1999
    Location
    Tilburg-Breda, Noord-Brabant, The Netherlands
    Posts
    135

    Background Color of a Panel

    Hi there,

    I've got a little problem setting the background color of a panel. I've got a Frame which layout is set to null. When I add a panel with a checkboxgroup, and use setBackground(Color.red). The panel is not red only the background of the checkboxes is red.
    Can you help me?

    Thanx,
    Jan Meeuwesen.


  2. #2
    Join Date
    Aug 1999
    Location
    San Diego
    Posts
    155

    Re: Background Color of a Panel

    Jan,

    Can you post the code? Or email me with the problem if its a concern.

    It sounds like you are setting the background of the checkbox to red, but I'm sure you would have noticed that.

    Dustin


  3. #3
    Join Date
    Nov 1999
    Location
    Tilburg-Breda, Noord-Brabant, The Netherlands
    Posts
    135

    Re: Background Color of a Panel

    Hi there and thanx for responding,

    I've found out something myselve. If I run my program, I see only colors behing the checkboxes. But if I minimize the window and maximize it again, Then the colors are perfect !! ?? I guess when I open my program java just does not take the time to make the background good. Any ideas???

    This is the piece of code I use for setting the color of my Panels:


    leftPanel = new Panel(null);
    leftPanel.setBackground(Color.gray);
    leftPanel.setBounds(0,0,200,400);
    middlePanel = new Panel(null);
    middlePanel.setBackground(Color.darkGray);
    middlePanel.setBounds(200,0,200,400);
    rightPanel = new Panel(null);
    rightPanel.setBackground(Color.gray);
    rightPanel.setBounds(400,0,200,400);





    Thanx,
    Jan Meeuwesen


  4. #4
    Join Date
    Mar 2001
    Posts
    4

    Re: Background Color of a Panel

    Try this: first you hide the panel and then you
    show it. Whith this you repaint the panel and
    when you minimize and maximize it will be repainted too. And with this metod it will be the same i think.

    leftPanel.setVisible(false);
    leftPanel .setVisible(true);

    If your panels laying in another panel
    changes "leftpanel" to that panels name.

    IK

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured