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?
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.
subject: Overriding the refresh method from the custom panel class.