This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Label with Image" Watch "Label with Image" New topic
Author

Label with Image

Stefan Seeba
Greenhorn

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){
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

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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Label with Image
 
Similar Threads
Applets and images...
Java Help non-HTML textpad
getting problem in creating an image from int array
Image Display Error
Context Graphic