[
Previous section |
Next section |
This Package |
Package List |
Table of Contents
]
Class ContainerItem
public class extend.awt.ContainerItem extends java.lang.Object {
public ContainerItem(Image, String)
public void addBefore(ContainerItem)
public void moveBefore(ContainerItem)
public void addAfter(ContainerItem)
public void moveAfter(ContainerItem)
public void addToFront(ContainerItem)
public void moveToFront(ContainerItem)
public void addToEnd(ContainerItem)
public void moveToEnd(ContainerItem)
public void setChildList(ContainerItem)
public void remove()
public String textFor()
public void setData(Object)
public Object getData()
public void setColumn(int, Object)
public int itemCount()
public int columnCount()
public Object getColumn(int)
public Object getColumns()[]
public ContainerItem getFirst()
public ContainerItem getNext()
public ContainerItem getPrevious()
public ContainerItem getLast()
public ContainerItem getItem(int)
public ContainerItem getParent()
public ContainerItem getFirstChild()
public void setExpanded(boolean)
public boolean isExpanded()
public void setSelected(boolean)
public boolean isSelected()
public void setImage(Image)
public Image getImage()
public void traverse(ItemProcessor, int)
}
The ContainerItem class represents the items which may be displayed and
managed by a DataContainer. It has many linked list and parent/child
relationship management methods which make it useful even outside of a
DataContainer.
ContainerItem
public ContainerItem (Image i, String labelText)
- This is the only constructor for the ContainerItem class.
- Parameters:
i -
This is the Image object to use as an icon in the
Icon view. This may be set to null if you are using only the Details,
List and/or Tree view.
labelText -
This is the label text for this item. This
string is displayed in the Icon, List and Tree views. It is not used in
the Details view.
addBefore
public void addBefore (ContainerItem item)
- This method adds the current item into the sibling list of the
specified item immediately before the specified item.
- Parameters:
item -
This is the item before which the current item
will be added.
moveBefore
public void moveBefore (ContainerItem item)
- This method moves the current item from its current list into
the sibling list of the specified item immediately before the specified
item.
- Parameters:
item -
This is the item before which the current item
will be moved.
addAfter
public void addAfter (ContainerItem item)
- This method adds the current item into the sibling list of the
specified item immediately after the specified item.
- Parameters:
item -
This is the item after which the current item
will be added.
moveAfter
public void moveAfter (ContainerItem item)
- This method moves the current item from its current list into
the sibling list of the specified item immediately after the specified
item.
- Parameters:
item -
This is the item after which the current item
will be moved.
addToFront
public void addToFront (ContainerItem item)
- This method adds the current item into the sibling list of the
specified item at the very beginning of the list.
- Parameters:
item -
This is the item whose sibling list the current
item will become the first of..
moveToFront
public void moveToFront (ContainerItem item)
- This method moves the current item from its current list into
the sibling list of the specified item at the very beginning of the
list.
- Parameters:
item -
This is the item whose sibling list the current
item will become the first of..
addToEnd
public void addToEnd (ContainerItem item)
- This method adds the current item into the sibling list of the
specified item at the very end of the list.
- Parameters:
item -
This is the item whose sibling list the current
item will become the last of..
moveToEnd
public void moveToEnd (ContainerItem item)
- This method moves the current item from its current list into
the sibling list of the specified item at the very end of the list.
- Parameters:
item -
This is the item whose sibling list the current
item will become the last of..
setChildList
public void setChildList (ContainerItem first)
- This method sets the given item as the child of the current
item. All items in the sibling list of the given item are considered
children of the current item.
- Parameters:
item -
This is the item which will be made the child of
the current item.
remove
public void remove ()
- This method removes the current item from the tree/list to which
it belongs. If there are any children, they are all removed as well.
textFor
public String textFor ()
- This method returns the label text of the item.
- Returns:
- This method returns void.
setData
public void setData (Object ref)
- This method sets the reference data object for this item.
- Parameters:
ref -
The object to keep as a reference for this item.
getData
public Object getData ()
- This method retrieves the reference data object for this item.
- Returns:
- This method returns Object.
setColumn
public void setColumn (int which, Object data)
- This method sets the object value for the specified column (zero
based). Columns may be specified in any order. These columns are only
displayed in the Details view.
- Parameters:
which -
The column number for which the data is
destined (zero based)
data -
The object to use as a value for the column. If
the object is a java.awt.Image, it will be rendered as such. Otherwise
its toString () method will be used to determine the string to display
as the column value.
itemCount
public int itemCount ()
- This method returns the number of items in this item's sibling
list.
- Returns:
- This method returns int.
columnCount
public int columnCount ()
- This method returns the number of columns which have been set in
this item.
- Returns:
- This method returns int.
getColumn
public Object getColumn (int which)
- This method returns the object value of the requested column
(zero based).
- Parameters:
which -
The column number for which the data is to be
retrieved (zero based)
- Returns:
- This method returns Object.
- Throws:
- IllegalArgumentException
This exception is thrown when any argument is not valid.
getColumns
public Object [] getColumns ()
- This method returns the array of column values for the item. If
no column values have been set, this method will return null.
- Returns:
- This method returns an array of String.
getFirst
public ContainerItem getFirst ()
- This method returns the first item in the item's sibling list.
- Returns:
- This method returns ContainerItem.
getNext
public ContainerItem getNext ()
- This method returns the item which follows this item in the
sibling list. If this is the last item in the list, null is returned.
- Returns:
- This method returns ContainerItem.
getPrevious
public ContainerItem getPrevious ()
- This method returns the item which precedes this item in the
sibling list. If this is the first item in the list, null is returned.
- Returns:
- This method returns ContainerItem.
getLast
public ContainerItem getLast ()
- This method returns the last item in this item's sibling list.
- Returns:
- This method returns ContainerItem.
getItem
public ContainerItem getItem (int which)
- This method returns the nth item in this item's sibling list
where 0 <= n < itemCount ()
- Parameters:
which -
The number of the item in the sibling list to
return (zero based).
- Returns:
- This method returns ContainerItem.
- Throws:
- IllegalArgumentException
This exception is thrown when any argument is not valid.
getParent
public ContainerItem getParent ()
- This method returns the item which is the parent of this item's
sibling list.
- Returns:
- This method returns ContainerItem.
getFirstChild
public ContainerItem getFirstChild ()
- This method returns the first item of the sibling list set as
the child of this item.
- Returns:
- This method returns ContainerItem.
setExpanded
public void setExpanded (boolean newValue)
- This method sets the expanded state of the child list for this
item. It is used to control the visibility of the child list in visual
controls such as DataContainer.
- Parameters:
newValue -
The visibility of the child list (true or
false).
isExpanded
public boolean isExpanded ()
- This method returns the expanded state of the child list for
this item.
- Returns:
- This method returns boolean.
setSelected
public void setSelected (boolean newValue)
- This method sets the selected state of this item.
- Parameters:
newValue -
Whether this item is selected or not (true
or false).
isSelected
public boolean isSelected ()
- This method returns the selected state of the item.
- Returns:
- This method returns boolean.
setImage
public void setImage (Image newIcon)
- This method sets the Image (icon) associated with this item.
- Parameters:
newIcon -
This is the new icon for this item.
getImage
public Image getImage ()
- This method returns the Image (icon) associated with this item.
- Returns:
- This method returns an Image.
traverse
public void traverse (ItemProcessor processor, int tag)
- This method steps through all siblings, children and children of
siblings. A callback method is used to allow any processing at each
ContainerItem (see ItemProcessor below). This may be used on subtrees
as processing will not go to the parent of the item whose traverse ()
method is invoked..
- Parameters:
processor -
This is the object whose processItem ()
method will be invoked for each item in the current item's sibling list
and tree. If the processItem () method returns false, traversal will
stop.
tag -
This is a tag value passed to the processItem ()
method to allow a single class use traverse () in multiple ways. See
the source for the DataContainer class for an example.
[
Previous section |
Next section |
This Package |
Package List |
Table of Contents
]