0

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.

4
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by javaAddict
0

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.

-1

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

Edited by happygeek: fixed formatting

Votes + Comments
Start a new thread. Don't hijack other old threads
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.