Quote:
Originally Posted by kalar
where, i mean in the jpanel or in the jframe?
The JPanel class extends the JComponent class and all the drawing is done
visually bounded by the JComponent/JPanel. The JPanel class itself doesn't
implement any paint method, i.e. it leaves that responsibility to its parent class.
If you extend the JPanel class and if you override the paintComponent() method
it's your code that paints in the area bounded by the JComponent (the ancestor
class of them all). Your class overrided the paintComponent() method so the
JCompontent's paint() method will call your paintComponent() method.
That's how overriding works and the JComponent class makes clever use of it.
If your paintComponent() method wants to clear the background area all it has
to do is call the super paintComponent() method and make the component
opaque when it is initialized.
The JComponent and therefore your extension of the JPanel class is part of the
container that happens to be a JFrame so yes, everything is visually drawn
inside the bounds of that JFrame.
kind regards,
Jos