aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Doh!  How do you draw a line on an image? 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 "Doh!  How do you draw a line on an image?" Watch "Doh!  How do you draw a line on an image?" New topic
Author

Doh! How do you draw a line on an image?

Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
First up I really appreciate any help here. I've been beating my head against the wall on this for days now, seaching the Internet looking for examples but no luck. All I want to do is draw some lines on some images and then erase them if needed. It really can't be that hard to do can it?
Currently I have a JApplet that loads images from a jar file. This applet can scale the images, and move them left right, up and down. Right now the JApplet loads an image, which is then converted to an ImageIcon, which is then used to create a JLabel, which is used to create a JScrollPane which finally gets added as a tab on a JTabbedPane. So, when you click a tab, you see an image. I then want to be able to draw a line on that image (I'll worry about placing the line where I want it later!).
I can get a line to draw on a copy of the image, but I cannot seem to get that image to draw where it is supposed to as it always draws in the upper left hand corner.
What I really want is for the new image (the image with a line in it) to replace the old image. The way it is now, both the old and new images still get drawn with the new one having a line on it.
Here is the code I have so far:

Again, I really appreciate any help you could give.
Thanks.
[ August 06, 2003: Message edited by: Darrin Smith ]
Geoff Griffiths
Greenhorn

Joined: Mar 18, 2001
Posts: 17
try the following link to the java 2d trail at sun. . http://java.sun.com/docs/books/tutorial/2d/problems/index.html
hope this helps
Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
Thanks.
That is one of the first things I looked at, and pretty much what I think I'm doing, but I appreciate the effort.
 
Consider Paul's rocket mass heater.
 
subject: Doh! How do you draw a line on an image?
 
Similar Threads
Converting points. Help!
how to edit a pictures
Question about drawimage
JPanel PaintComponent method gives OutOfMemoryError
AffineTransform make an image move