Solved

Why super.paint(g)?

Posted on 2004-09-15
3
328 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 125 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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

705 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