borland.jbcl Packages borland.jbcl Class Hierarchy borland.jbcl.control
java.lang.Object +----java.awt.Component +----java.awt.Container +----java.awt.ScrollPane +----borland.jbcl.view.TreeView +----borland.jbcl.control.TreeControl
Variables Constructors Properties Methods Event Listeners
Implements GraphModel, WritableGraphModel, BlackBox, GraphView, MenuContainer, ImageObserver, Serializable
The TreeControl component displays a hierarchical list of items (nodes), such as the headings of a document, the entries in an index, or the directories and files on a disk. Each node (except the root node, or origin of the tree) has a parent node from which it descends. It may or may not have one or more sibling nodes (descendants from the same parent) and one or more children nodes (descendants from itself). By clicking on the graphic beside a node, the user can expand and collapse the associated list of sub-nodes (children). Nodes in a TreeControl are of type LinkedTreeNode
Use the style() method to select from a list of platform-specific display styles. The selection property is the currently selected node.
TreeControl is a composite component that instantiates a default graph data model (BasicTreeContainer), item painter (SelectableTextItemPainter), and view manager (BasicViewManager).
You can show both text and a graphic on each TreeControl node, to create a basic file-manager directory tree with folder images and strings showing the directories. The default item viewer (SelectableTextItemViewer) won't work for this. You need a CompositeItemViewer made up of a ImageItemViewer (or StateImageItemViewer to show open and closed folders) and a SelectableTextItemViewer. You can use these classes with the TreeControl and LinkedTreeContainer. To use TreeControl, drop it in the UI Designer. Everything else for such composite nodes needs to be coded.
Here are some sample uses of tree (data):
TreeControl tree = new TreeControl();
GraphLocation root = tree.setRoot("Monkey");
root = tree.setRoot(new Color(234, 234, 22));
root = tree.setRoot(myCustomClassThingie);
GraphLocation node = tree.addChild(root, "Monkies");
node = tree.addChild(root, new Color(24, 4, 2));
node = tree.addChild(myCustomClassThingie2);
GraphLocation found = tree.find("Monkies");
System.out.println("This should print out 'Monkies' = " + tree.get(found));
System.out.println("A node's value : " + tree.get(node));
System.out.println("Der root : " + tree.get(tree.getRoot()));
public TreeControl()Constructs an empty TreeControl with default property values.
public void setModel(borland.jbcl.model.GraphModel model)
Checks for recursive model creation, then calls super.setModel(model), which is borland.jbcl.view.TreeView.setModel().
public GraphLocation getRoot()
Returns the root node for this graph. Uses getRoot() of the GraphModel.
public boolean isVariableSize()
Uses isVariableSize() of the WriteableGraphModel to check whether the tree control can have items inserted.
public void addActionListener(java.awt.event.ActionListener l) public void removeActionListener(java.awt.event.ActionListener l)
public synchronized void addComponentListener(java.awt.event.ComponentListener l) public synchronized void removeComponentListener(java.awt.event.ComponentListener l)
public synchronized void addContainerListener(java.awt.event.ContainerListener l) public void removeContainerListener(java.awt.event.ContainerListener l)
public void addFocusListener(java.awt.event.FocusListener l) public void removeFocusListener(java.awt.event.FocusListener l)
public void addKeyListener(java.awt.event.KeyListener l) public void removeKeyListener(java.awt.event.KeyListener l)
public void addModelListener(borland.jbcl.model.GraphModelListener listener) public void removeModelListener(borland.jbcl.model.GraphModelListener listener)
public void addMouseListener(java.awt.event.MouseListener l) public void removeMouseListener(java.awt.event.MouseListener l)
public void addMouseMotionListener(java.awt.event.MouseMotionListener l) public void removeMouseMotionListener(java.awt.event.MouseMotionListener l)
public void addSelectionListener(borland.jbcl.model.GraphSelectionListener listener) public void removeSelectionListener(borland.jbcl.model.GraphSelectionListener listener)
public void addSubfocusListener(borland.jbcl.model.GraphSubfocusListener l) public void removeSubfocusListener(borland.jbcl.model.GraphSubfocusListener l)
public void addTreeListener(borland.jbcl.view.TreeListener l) public void removeTreeListener(borland.jbcl.view.TreeListener l)