Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting color  RSS feed

 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am looking at a bunch of JLabel objects on a panel. Some of them are yellow while most of them are white. I want to access this information so I'm using
jLabel.getGraphics().getColor()
to give the the Color object. However, from this point all the Color methods are giving me the same information no matter what the color is. Is there something I need to know about getting the color of a JLabel text? I don't have access to the code that builds these labels.
Thanks.
Paul
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,
did you tried JLabel.getForeground() and JLabel.getBackground()?
Because if you ask the Graphics object, it will return the last color, which was set and you don't know which color will be set the last time, when a JLabel calls it's paint method.
Hope this helps
Rene
 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This helps a lot. The Foreground color being returned does show up a different value for the different colors - which is exactly the information I need.
Many thanks!
Paul
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!