File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Draw on a Jlabel Icon Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Draw on a Jlabel Icon" Watch "Draw on a Jlabel Icon" New topic
Author

Draw on a Jlabel Icon

hans teeuwen
Greenhorn

Joined: Dec 20, 2009
Posts: 2
I want to draw a line on a picture. The picture is being drawn on a jpanel.

Code voor JPanel with image


Code for drawing a line on the image



I have tried the following;


Could someone please tell me what i'm doing wrong.
Hiram Nascimento
Greenhorn

Joined: Jul 09, 2009
Posts: 13
Hi Hans,

I see you are creating a "JLabel" and then adding the Meter object into it.

Why don't you just "paint" the SpeedMeter with the image you need in the background and just add "SpeedMeter" in the JPanel?

- Set up the background image in the SpeedMeter paintComponent() (once it's a JLabel).
- Don't forget to use the repaint() method if you need to update the "Meters"
- Once you have done that, just instantiate a SpeedMeter and add it to the panel object.

Does it make sense?

Thanks,
Hiram
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Draw on a Jlabel Icon
 
Similar Threads
I'm stuck!
JPanel on JScrollBar possible?
How do I layer components on top of each other without blocking lower components?
Fading in/out an image - please help...
How to add icons along with the text in a JList[urgent]