aspose file tools*
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 Soft Skills this week in the Jobs Discussion 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: 2400
    
  50
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPanel not updating after drawing on it.