• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Panel Background

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am dealing with a Webstart application and having issues with Panel background color.

The applet's background is as follows

Color cl = (Color) Toolkit.getDefaultToolkit().getDesktopProperty("win.desktop.backgroundColor");

Which is set to black (Red=0,Green=0, Blue=0).

Then I added a panel. It's background comes up as blue.
No matter what I try, that background stays always blue.

Since the code was developed by someone else, I don't know how to over-ride it.

I even tried

UIManager.put("Panel.background", Color.LIGHT_GRAY);

This changes the inner panel's color, but not the outer panel.

Can someone help?
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your title says "Panel background" but then you start asking about an applet's background. And then you're talking about "inner" and "outer" panels which I don't understand what they are.

And first you implied that you couldn't change the code, but then you said you changed the code by calling a UIManager method. So that's a bit confusing too.

I'm guessing that this is a JPanel whose background colour you want to change, but even if it's an antique AWT Panel both classes still support the setBackground(Color) method, so using that method would be the most straightforward way to deal with the problem.

Please don't hesitate to provide more details if my guesses are off track.
 
dakshina gandikota
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will try to draw a picture for you

I am able to set the background of Inner Panel.
I would like to set the background of Outer Panel, which I am unable to do.
I also called setBackground and setForeground methods of outer panel without luck.

I have also tried UIManager.put("Frame.background", Color.GREEN);

Regards
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't play with the UIManager.

Just use:



If you need more help then post a proper SSCCE that demonstrates the problem.
 
dakshina gandikota
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am unable to post code at this time.

I already have tried panel.setBackground(color).

Please see my reply to Paul.

Thanks
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like maybe your panel has a border, then. So you'd have to set its colour separately from the panel it's bordering.
 
Rob Camick
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am unable to post code at this time.



Then we can't help at this time.

All you need is setBackground(). The setBackground() method has existed ever since Java GUI's existed.

If it doesn't work then you are doing something strange and we can not possibly guess what that might be.
 
Rob Camick
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cross posted: http://stackoverflow.com/questions/39133171/swing-panel-background-color-could-not-be-changed

No surprise that the answer is the same.

You need to post a SSCCE to demonstrate the problem!!!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic