Solved

Why super.paint(g)?

Posted on 2004-09-15
3
303 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
  • 2
3 Comments
 
LVL 92

Expert Comment

by:objects
Comment Utility
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
Comment Utility
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 125 total points
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now