Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Trying to update gui when clicking on mouse  RSS feed

 
Niels Tielenburg
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I try to change a circle to be filled or not filled when I click on the circle. But with this code:
it doesn't work, anybody an idea?
 
Rob Spoor
Sheriff
Posts: 21047
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't ever store the Graphics object. You are getting a new Graphics object each time you call repaint, so you are painting on an old Graphics object that is no longer used for the actual painting. Use repaint() instead.

Also, don't override paint and then call super.paintComponent. Override paintComponent instead, and keep it protected.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might find this useful http://java.sun.com/products/jfc/tsc/articles/painting/
Please note, it talks about AWT and Swing painting approaches which differ.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!