Link to home
Start Free TrialLog in
Avatar of HanRui
HanRui

asked on

Why super.paint(g)?

I have a JApplet with a paint method drawing a string. I construct and add a JLabel to the content pane. I understand the directions to use super.paint(g), and I see what happens when I leave it out (no label). But for the life of me I don't understand what is happening with the call to the Applet's (the superclass) paint method, sending up the graphics context.
Avatar of Mick Barry
Mick Barry
Flag of Australia image

The superclass is responsible for painting the applet child components (ie. your label), so if you don't call super.paint() the labels paint() method will not get called.
Avatar of HanRui
HanRui

ASKER

There must be something going on behind the scenes because the paint method in the superclass is empty and overridden. That's my problem. The paint method that paints the label in the superclass is somehow hidden. Isn't that true?
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial