aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Paint program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Paint program" Watch "Paint program" New topic
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: 2092
    
    7
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: 4523
    
    5

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: 36514
    
  16
I think this discussion ought to be moved to our GUIs forum
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Paint program
 
Similar Threads
How can i use mouse to click on an image and draw a point after i clicked ?
Movable Objects
How to add MouseLsitener to JMenu
adding graphic objects to JPanel
Tooltip on Line2D or Rectangle2D