Two Laptop Bag
The moose likes Swing / AWT / SWT and the fly likes Label with Image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Label with Image" Watch "Label with Image" New topic

Label with Image

Stefan Seeba

Joined: Oct 24, 2000
Posts: 5
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){
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,
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
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.

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link:
subject: Label with Image
It's not a secret anymore!