I have a code like that:
// In MyPanel.java
public void paintComponent(Graphics g)
{
super.paintComponent(g);
// Draw something
mypanel_count++;
understand that you do not have complete control over if or when paint(...) get's called, and that repaint() calls are only a suggestion to the JVM to paint. If too many repaint() requests come in and they stack up as yours are doing, then they will be combined
refer : https://stackoverflow.com/a/13256847/1423083