| Author |
Paint program
|
aarti bashyam
Greenhorn
Joined: Aug 21, 2008
Posts: 1
|
|
I am writing a program where if the user clicks, it should draw a point. The following code does not seem to work properly. If I click, it draws a point but vanishes later on. I tried using paint and paint component but I am not able to use them. Please help!!
|
 |
Rob Camick
Ranch Hand
Joined: Jun 13, 2009
Posts: 1788
|
|
Please use the "Code" tags when posting code.
You can start with the Swing tutorial on Custom Painting for a working example that you can modify.
|
 |
Yunnan Zhou
Ranch Hand
Joined: May 04, 2011
Posts: 31
|
|
just remove repaint() in you method mousePressed() and try again.but it's not a good way.
if you want your points stay and not vanishes.you must save them in a collection .everytimes you press ,repaint all point which in you collection.
|
I'am a Chinese.I like Java.Hello.
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4164
|
|
aarti, welcome to the Ranch! We don't have too many rules around here, but we do ask that you BeForthrightWhenCrossPostingToOtherSites <-- link
|
luck, db
There are no new questions, but there may be new answers.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32654
|
|
|
I think this discussion ought to be moved to our GUIs forum
|
 |
 |
|
|
subject: Paint program
|
|
|