why PaintComponent event in Java happen everytime I use its Graphics Event?

Posted by Pooya on Stack Overflow See other posts from Stack Overflow or by Pooya
Published on 2009-11-22T18:07:48Z Indexed on 2010/03/27 9:03 UTC
Read the original article Hit count: 280

Filed under:
|
|

Consider this code:

public class StateChartPanel extends JPanel {
    private LightContext LC;

    public StateChartPanel(LightContext lc){
        LC=lc;
    }
    public void paintComponent( Graphics G ){           
        super.paintComponent( G );
        LC.DrawStateChart((Graphics2D)G);     
    }
}

StateChartPanel is a panel to draw something (a state chart). It sends its Graphics object to LC which use it to draw shapes but whenever it draws something the PaintComponent event of StateChartPanel happens again and it causes my application to hang.

© Stack Overflow or respective owner

Related posts about java

Related posts about event