• 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

Label with Image

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi !
I need to place a small image behind the text of a label. For compatibility reasons I have to work with the normal AWT (no Swing, no JLabel with icon).
My approach was to inherit from Label, edit the paint-method and add an image there.
class ImLabel extends Label {
...
public void paint(Graphics g){
drawImage(...;
super.paint(g);
}
}
But the effect is that the image is always in the foreground.
Is there a chance to get the image into the background and the letter(s) on top ?
Best regards,
Stefan
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Label is a component. Component implements ImageObserver. The method inherited from this is ImageUpdate. This is the thing that causes a button to have a certain look etc.
Perhaps you can override ImageUpdate to include a repaint of your image, which would put it in the background, and the text would be on top.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic