| Author |
Extending a Swing component
|
Ganesha Kumar
Ranch Hand
Joined: May 04, 2006
Posts: 56
|
|
Hi all,
In lot of Swing samples I see that a component, say, JFrame being extended. The extending class simply sets the properties or adds children to the super class. This is a not proper way, right? What is the purpose of extension if you are not modifying the behavior of the superclass?
Thanks,
Ganesh
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8439
|
|
Why do you think it is not the right way?
By overriding, you can modify the behavior.
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
Ganesha Kumar
Ranch Hand
Joined: May 04, 2006
Posts: 56
|
|
|
It is not a proper way because the subclass is simply making use of superclass. It is not modifying any behavior of the superclass
|
 |
Rob Camick
Ranch Hand
Joined: Jun 13, 2009
Posts: 1788
|
|
|
That is correct is not the proper way to create a frame. Most examples do it out of lazyness. It you want to see a better approach look at the examples in the Swing tutorial.
|
 |
Ganesha Kumar
Ranch Hand
Joined: May 04, 2006
Posts: 56
|
|
|
Can you please provide the link to Swing tutorial?
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8439
|
|
Try www.google.com
Searching for "swing tutorial" usually works
|
 |
Ganesha Kumar
Ranch Hand
Joined: May 04, 2006
Posts: 56
|
|
|
Ok. Thanks Maneesh
|
 |
 |
|
|
subject: Extending a Swing component
|
|
|