When in a program is the paint method called?? I've looked through example coding previously, it takes an arg of Graphic g. However I cannot see where it is called, or what is sent to the method to be taken in as an argument. Suppose I had a jpanel and a jtextarea, how could I say that I wanted to paint on the jpanel, as opposed to anywhere else???
The paintComponent( ... ) method is called by the EDT (Event Dispatch Thread). Whenever it thinks that something needs to be repainted it calls that method. It constructs a Graphics object and passes it to the method. Don't call it yourself but call the repaint() method instead. Eventually the paintComponent( ... ) method is called. There's an explanation about this 'passive drawing' in the Swing tutorial.
Originally Posted by larry_d1990