| Author |
How to reset jpanel...
|
Maria Sachhause
Greenhorn
Joined: Nov 30, 2005
Posts: 10
|
|
I have a drawing panel where I can draw lines etc. Program works like this: 1. First mouse click makes start point (coordinates) 2. Second mouse click makes destination point (coordinates) 3. Line is drawn between those points 4. Third click draw a line from it coordinates toward center of jpanel problem is this.... How to make Jbutton RESET, which set panel empty(as it was when program where started)without restarting. What is the easiest way to do that?
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8441
|
|
Originally posted by Maria Sachhause: .... How to make Jbutton RESET, which set panel empty(as it was when program where started)without restarting. What is the easiest way to do that?
super.paintComponent(Graphics g)
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
Craig Wood
Ranch Hand
Joined: Jan 14, 2004
Posts: 1535
|
|
Some ideas: 1 — you can reset the member variables (x1, y1, ...) to be equal or offscreen, eg, -1 so that they are not drawn when the component repaints itself after you call repaint; 2 — you can use a member variable boolean in your paintComponent method which you control from your event code to turn on/off drawing of the lines.
|
 |
 |
|
|
subject: How to reset jpanel...
|
|
|