• Post Reply Bookmark Topic Watch Topic
  • New Topic

Extending a Swing component

 
Ganesha Kumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you think it is not the right way?
By overriding, you can modify the behavior.
 
Ganesha Kumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please provide the link to Swing tutorial?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try www.google.com
Searching for "swing tutorial" usually works
 
Ganesha Kumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. Thanks Maneesh
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!