Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Why super.paint(g)?

Posted on 2004-09-15
3
Medium Priority
?
349 Views
Last Modified: 2012-06-21
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.
0
Comment
Question by:HanRui
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 92

Expert Comment

by:objects
ID: 12071187
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.
0
 

Author Comment

by:HanRui
ID: 12071210
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?
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 12071264
What do you mean it's hidden?
Are you looking at the source for the superclass(s).

Applet and Panel don't actrually define a paint() method, so super.paint() will in fact result in the paint method in Container getting called.
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question