Hi,

I have a program that draws a line between two points when the user clicks at two points on a canvas (added in a frame) and clicks Repolot button.

Each time i click the button the previous line is gone. But i want that when i click the button the previous line remains there and new line is also drawn on the canvas.

I am using repaint() so it is not possible to keep the previous line there. Can someone suggest me another way to do this?

Thanks.

Member Avatar for iamthwee

Hi,

I have a program that draws a line between two points when the user clicks at two points on a canvas (added in a frame) and clicks Repolot button.

Each time i click the button the previous line is gone. But i want that when i click the button the previous line remains there and new line is also drawn on the canvas.

I am using repaint() so it is not possible to keep the previous line there. Can someone suggest me another way to do this?

Thanks.

What happens if you were to store the coords of the last buttons clicks in an array. Then on repaint draw the previous line using the info stored in the array whilst draw the new line?

And so on.

I want to draw a line in swing.
Please help me.

commented: Start a new thread. Don't hijack other old threads -2

I want to draw a line in swing.
Please help me.

Thanks.

Start a new thread. Did you even bother to look the date of this thread? It is 3 years old.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.