Class de.unikl.AWTNode.AWTNode
All Packages Class Hierarchy This Package Previous Next Index
Class de.unikl.AWTNode.AWTNode
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----de.unikl.AWTNode.cfContainer
|
+----de.unikl.AWTNode.NodeContainer
|
+----de.unikl.AWTNode.RescanNode
|
+----de.unikl.AWTNode.AWTNode
- public class AWTNode
- extends RescanNode
The Class AWTNode implements a new Java Component.
With this class you are able to build an tree-structure which
can be shown on the screen. (e.g. a File/Directory tree like
in the Windows explorer)
What I have to do: -how to create a tree-
First you create a "root"-Node and then you insert into this
node a new AWT components. On the one hand these components
can be "ordinary" components like Buttons or Lables
on the other hand these components can be new AWTNode´s.
If you insert a new AWTNode to your "root"
node with the insert(...) method you just have merged two tree´s
together, and you have build a tree with excatly two nodes.
If you continue to insert other instances of AWTNode the
tree gets "bigger".
as a result you can say:
The tree is build out of single AWTNodes
example:
root =new AWTNode(new Button("root-node")); // the whole tree
root.insert(new Button("autoexec.bat")); // a simple "File"
root.insert(new AWTNode(new Button("[DOS]"))); // a Subdir
Constructs:
[c]-[root]
|
+------autoexec.bat
|
+------[c]-[DOS]
and [c] means a Checkbox.
In front of each AWTtree we draw a Checkbox.
The interface to build a tree is quite simple. (You shouldn´t need
the superclasses like RescanNode or NodeContainer,
the best thing is to ignore them)
In general a AWT"tree" will work as expected and you won´t need
the superclasses.
internal implementation:
The source code is a typical "treeimplemetation"
Like in the "ordinary" tree-structure there is a "key" and the
"pointer" to the sons
+------+
| key |
+----------+------+---+
| | |....
son 1 son 2 son i
The only thing which might be confusing is the fact that
the "key" in this implementation is a AWT-component (and not
an integer) But this is because this implemennts an *AWT* tree,
and thus the "keys" have to be components.
In general the tree is filled with the insert methods. Because
this is a recursive approch most of the methode in AWTNode
work recusivley on the "sons"
You can connect a ActionListener with a AWTNode node.
Then this ActionListener receives "open" and "close" events.
-
AWTNode()
-
-
AWTNode(Component)
- Constructs a new AWTtree with a component as its graphical representation
-
addActionListener(ActionListener)
- Adds the specified action listener to receive action events
from this button.
-
countSons()
- returns the number ob sons in the AWTNode
-
getKey()
- returns the key-Component of this node
-
getSons()
- returns all the sons of this AWTNode
sons are simple Components as well as AWTNodes...
-
insert(Component)
- Inserts a son to this Node
A son may be an ordinary Component or an AWTNode.
-
processActionEvent(ActionEvent)
- Processes action events occurring on this button by
dispatching them to any registered ActionListener objects.
-
processEvent(AWTEvent)
- Processes events on this button.
-
removeActionListener(ActionListener)
- Removes the specified action listener so it no longer receives
action events from this button.
-
removeAllSons()
- removes all sons from this node
-
setKey(Component)
- sets a new Key for this AWTNode
-
setState(boolean)
- "opens" or "closes" a AWTNode
The "open" or "close" event is passed
to the listner before the
event is passed to its superclass
AWTNode
public AWTNode()
AWTNode
public AWTNode(Component key)
- Constructs a new AWTtree with a component as its graphical representation
getKey
public Component getKey()
- returns the key-Component of this node
setKey
public void setKey(Component key)
- sets a new Key for this AWTNode
countSons
public int countSons()
- returns the number ob sons in the AWTNode
getSons
public Component[] getSons()
- returns all the sons of this AWTNode
sons are simple Components as well as AWTNodes...
- Returns:
- array of Sons
insert
public void insert(Component son)
- Inserts a son to this Node
A son may be an ordinary Component or an AWTNode.
removeAllSons
public void removeAllSons()
- removes all sons from this node
setState
public void setState(boolean check)
- "opens" or "closes" a AWTNode
The "open" or "close" event is passed
to the listner before the
event is passed to its superclass
- Parameters:
- check - false="open" the AWTNode /true ="close" it
- Overrides:
- setState in class RescanNode
addActionListener
public void addActionListener(ActionListener l)
- Adds the specified action listener to receive action events
from this button.
- Parameters:
- l - the action listener
removeActionListener
public void removeActionListener(ActionListener l)
- Removes the specified action listener so it no longer receives
action events from this button.
- Parameters:
- l - the action listener
processEvent
protected void processEvent(AWTEvent e)
- Processes events on this button. If the event is an ActionEvent,
it invokes the processActionEvent method, else it invokes its
superclass's processEvent.
- Parameters:
- e - the event
processActionEvent
protected void processActionEvent(ActionEvent e)
- Processes action events occurring on this button by
dispatching them to any registered ActionListener objects.
NOTE: This method will not be called unless action events
are enabled for this component; this happens when one of the
following occurs:
a) An ActionListener object is registered via addActionListener()
b) Action events are enabled via enableEvents()
- Parameters:
- e - the action event
- See Also:
- enableEvents
All Packages Class Hierarchy This Package Previous Next Index