*
The moose likes Swing / AWT / SWT and the fly likes JPanel not updating after drawing on it. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JPanel not updating after drawing on it." Watch "JPanel not updating after drawing on it." New topic
Author

JPanel not updating after drawing on it.

Claudiu Constantinescu
Greenhorn

Joined: Mar 25, 2013
Posts: 3
Hello everyone, I'm working on tictactoe game and I have this panel which has two arraylists one for Xs and one for 0s.
When my server validates a move it sends it to players who add that move to one of the X or O arraylist and then it calls the repaint method.
BUT, the problem is that the repaint doesn't work for the first lets say 3 4 moves.After that the panel repaints as it should.
So, I'm trying to repaint this panel after adding a Point to myMoves or hisMoves ArrayLists.
I'll add that panel code here.
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2173
    
  47
I can't see anywhere that calls repaint() is it in another class.
BTW if you are calling addMyMove() or addHisMove() on a thread other than the EDT then you should add some synchronization.
Claudiu Constantinescu
Greenhorn

Joined: Mar 25, 2013
Posts: 3
I found the problem, it was the null parameter of the observer on drawImage() method and it was changed with 'this' . Maybe this will help someone else someday.
Solved and close.
 
 
subject: JPanel not updating after drawing on it.
 
Similar Threads
Magnifying only a part of the image
how to type text on an image
Stamping an Image
getRGB() causing problem!
Scrolling Components