Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overriding the refresh method from the custom panel class.

 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to let the refresh method be abstract from my custom panel class
since I need to refresh the inherited panels when things have changed (they are added to
a JTabbedPane). Now my question is should I put the initialization code there within
the refresh method so that it can be reused as well.
But my problem is as the object of those panels are member
variables of the parent class, all the listeners could have been
added twice and some peculiar results would come out.
I thought about divide them into 2 methods. One called
setup(), one refresh(), setup() is used for
initalization and refresh() is used for
JTabbedPane refreshing, but I don't know if I have done too much
for the class. What do you think?
Thanks
Jack
 
Tony Docherty
Bartender
Posts: 2958
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure I fully understand your problem but what I can say is a method should do exactly what it's name implies it does and nothing more. Methods should also be named to suggest they do one thing as per your method name of refresh. So, as your method is called refresh it should not be doing setup, that task is for a method called setup, initialise or some other such name.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic