Java repaint not working properly

I use the java repaint method, it redraws, but the update is visible only when I either click on the canvas or resize the panel. How can i fix this? What causes it?

+5
source share
3 answers

You need to call the revalidate () method. This forces the layout manager to update / redraw all of its components.

+15
source

repaint () does not actually redraw, it just asks for the component to redraw.

+2
source

Graphics , . Graphics. :

g = component.getGraphics(); 
draw(g);
0
source

All Articles