Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to retrieve constant for bg-color of a JPanel?

 
Andy Jung
Ranch Hand
Posts: 150
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Defining a central constant referring to the default background color of a JPanel I do the following as a first approach:


Works fine, however, is it really necessary to create a new object in order to retrieve that specific color, or is there any constant defined in the SE-API I can use directly instead?
 
Rob Spoor
Sheriff
Pie
Posts: 20368
43
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
UIManager.getColor("Panel.background") should do the trick.
 
Andy Jung
Ranch Hand
Posts: 150
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that's exactly 100% what I needed!
Thanks!
 
Rob Spoor
Sheriff
Pie
Posts: 20368
43
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
Andy Jung
Ranch Hand
Posts: 150
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob, is there a list anywhere presenting all those literals like "Panel.background" ?
 
Rob Spoor
Sheriff
Pie
Posts: 20368
43
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There may be lists on the Internet but I don't know of any. You can create such a list yourself though. Unzip the src.zip file in your JDK folder, go to folder javax/swing/plaf/basic and check each file. That's how I found this one.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick's UIDefaults.java will give you most, but read the comments for limitations

http://tips4java.wordpress.com/2008/10/09/uimanager-defaults/
 
Andy Jung
Ranch Hand
Posts: 150
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... ok, thanks guys again for your great help and hints !
Rob Camicks tool is pretty nice, he also has some precious threads!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic