File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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: 2215
    
    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: 4658
    
    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: 39791
    
  28
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