why PaintComponent event in Java happen everytime I use its Graphics Event?
- by Pooya
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.