Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Use custom components?  RSS feed

 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have just created my first custom component which extends JButton so that I can rapidly add buttons to my applications that have behaviour such as borders that appear on roll-over, and a few other little tweaks that I use regularly in my apps.
Whilst developing this all new component class, I began to realise the possibilities for using this technique across the board - for example, creating a new class to extend all of the standard Swing components so that they enable me to create sophistocated components from my GUI classes using a single line of code, letting my custom component class do all the hard work, rather than adding functionality line by line using the methods of the standard components such as setToolTipText() and setBorderPainted() etc etc.
I'm fairly new to the concepts of OOP, having just got to grips with Java basics and I would be interested to know what peoples opinions are about how far this sort of approach should be used. Basically, can anyone see any drawbacks to writing my own set of classes which add another level of abstraction between my applications and the Swing API?
Your opinions would be appreciated.
Ben.
 
Vinod Venugopal
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I assure u theres no problem to following the approach u have adopted. Infact if u have to use your custom components in a lot of places or reuse , then its best to customize Java's components & create your own. In this way you will get to learn more about extending & creating your own components. Also depends upon design specifications.
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Vinod.
Then my next project will be to develop a whole library of customised components for everyday use!!! This should speed up my app development time no end, as I seem to spend half my time setting up all the fetures of my GUI components at the moment, which is a particular problem if I decide to change the behaviour of all my buttons half way through a project. Now I can just edit one class and all the components will change. Nice one :-)
cheers,
Ben.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!