Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPanel not updating after drawing on it.

 
Claudiu Constantinescu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2965
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic