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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply 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: 1788
    
    2
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
    
    3

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
    
    4
I think this discussion ought to be moved to our GUIs forum
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Paint program
 
Similar Threads
How to add MouseLsitener to JMenu
adding graphic objects to JPanel
Movable Objects
How can i use mouse to click on an image and draw a point after i clicked ?
Tooltip on Line2D or Rectangle2D