A
Arun
Hi.
I am developing a GUI.
I'm not quite sure what to do when i encounter listeners. To keep
things tidy, i create a new class which implements a listener that i
want to use, then join that listener to a component.
For example, a listener that is called when a JTree node is selected is
called BuildTreeSelectionListener (implementing treeselectionlistener).
Then i use buildTree.addSelectionListener(new
BuildTreeSelectionListener).
What i dont get is this...
BuildTreeSelectionListener is called, and gets the node that has just
been selected. I now want this class to reference a method
onNodeSelection in my gui class (SwingMainView).
To do this, i have to set that method to static, then call
SwingMainView.onNodeSelection(). To me this doesnt seem like good code?
What do people usually do? Do they just implement the listener in the
class that it has been called from, instead of creating a new class for
it?
On a totally different point, has anyone got a good resource for the
proper use of keyword 'super'. I cannot find one.
I am developing a GUI.
I'm not quite sure what to do when i encounter listeners. To keep
things tidy, i create a new class which implements a listener that i
want to use, then join that listener to a component.
For example, a listener that is called when a JTree node is selected is
called BuildTreeSelectionListener (implementing treeselectionlistener).
Then i use buildTree.addSelectionListener(new
BuildTreeSelectionListener).
What i dont get is this...
BuildTreeSelectionListener is called, and gets the node that has just
been selected. I now want this class to reference a method
onNodeSelection in my gui class (SwingMainView).
To do this, i have to set that method to static, then call
SwingMainView.onNodeSelection(). To me this doesnt seem like good code?
What do people usually do? Do they just implement the listener in the
class that it has been called from, instead of creating a new class for
it?
On a totally different point, has anyone got a good resource for the
proper use of keyword 'super'. I cannot find one.