Rob Camick wrote:Custom Painting Approaches shows a couple of different ways. It draws a Rectangle but you can change it to paint a dot. It draws on a JPanel but you can change it to draw on a JLabel with an ImageIcon.
Michael Dunn wrote:in your mousePressed/Clicked code:
you update some variables with the coordinates from the mouseEvent
draw the red dot using the info from the (above) variables
> I also need to save and show the coordinate where i clicked.
save where? in a file - you should be able to do that
show where? a JLabel? - just update the label's text with the coords (can be done from mousePressed/Clicked)
Ulf Dittmer wrote:
but cannot work .....
Why not? How did you do it, and what happened?
Ulf Dittmer wrote:What stops you from adding the same MouseMotionListener to the ImageCapture object?
Ulf Dittmer wrote:Can you describe in words what you mean by "the coordinate on a buffered image"? What are the inputs, and what are the outputs? The code you posted is very thinly commented, and doesn't make clear what the end result should be.
salvin francis wrote:As suggested in the other posts by me, have you looked at the java2d api ?
You can use Canvas/JFrame/Frame to draw the points. though Frame is a part of awt and you are better off with JFrame/Canvas for your requirement.
Please do go through basic code for java2d/awt/swing before trying out complex examples.
David Newton wrote:You're going to have to be more specific about the actual problem you're having.
So far it looks like you don't know how to draw a smooth line given a limited set of data points. There are an arbitrary number of ways to do that--which works best for you can only be decided by you. If this is the problem, search the web for various line-drawing algorithms and pick which one you think works best.