aspose file tools
The moose likes Swing / AWT / SWT and the fly likes Extending a Swing component Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Extending a Swing component" Watch "Extending a Swing component" New topic
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
    
    2
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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Extending a Swing component
 
Similar Threads
getTreeLock()
Listening to the Mouse
Confusing
About Canvas and Swing
doubt with this component