• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Paint program

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!


 
Rancher
Posts: 3204
29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 31
MyEclipse IDE C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
aarti, welcome to the Ranch! We don't have too many rules around here, but we do ask that you BeForthrightWhenCrossPostingToOtherSites <-- link

 
Marshal
Posts: 70219
282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this discussion ought to be moved to our GUIs forum
 
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic