View Single Post
  #4 (permalink)  
Old 11-22-2009, 07:15 PM
Singing Boyo Singing Boyo is offline
Senior Member
 
Join Date: Mar 2009
Posts: 392
Rep Power: 2
Singing Boyo is on a distinguished road
Default
Originally Posted by Arnold View Post
Why don't you put this in the advanced section?
Seriously this is not intended for beginners.
Graphics painting itself is a beginners topic, and while a fully fledged paint program is not, this is a simple 'click and draw' program to many of us - I've had to do quite a few of these.

In answer to the OPs question, you'll somehow have to track what pixels are painted on. Your best bet is to track the points the user paints to, and then just redraw the entire 'picture' every time the paintComponent() method is called. I'd suggest an ArrayList<Point> or some other form of list (a Vector? Seems unnecessary as you don't have multi-threading) Make sure that update() looks something like this, or you may have problems...

Code:
public void update(Graphics g){
     super.update(g);
     paintComponent(g);
}
__________________
If the above doesn't make sense to you, ignore it, but remember it - might be useful!
And if you just randomly taught yourself to program, well... you're just like me!
Reply With Quote