This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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: 2158
    
  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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JPanel not updating after drawing on it.
 
Similar Threads
how to type text on an image
Stamping an Image
getRGB() causing problem!
Magnifying only a part of the image
Scrolling Components