Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Label with Image

 
Stefan Seeba
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic