|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Canvas | +--widgets.awt.Tree
This class implements a tree widget: a graphical representation of hierarchical data.
The widget supports ActionListener and PopupMenuListener objects. Registered listeners will be notified when a node is double clicked or when a popup menu is requested. Note that TreeNode objects also support these listeners. It is up to the programmer to decide at which level to handle events.
Scroll bars are not directely supported by this widget. If you want a scrollable tree you'll have to put this component in a ScrollPane.
TreeNode
, Serialized FormFields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT,
CENTER_ALIGNMENT,
LEFT_ALIGNMENT,
RIGHT_ALIGNMENT,
TOP_ALIGNMENT |
Constructor Summary | |
Tree()
Default constructor. |
|
Tree(java.net.URL openDirectoryIconURL,
java.net.URL closeDirectoryIconURL,
int parentLineOffset)
Create a tree widget that will display the specified open/close directory icons before each directory in the tree. |
Method Summary | |
void |
addActionListener(java.awt.event.ActionListener l)
|
void |
addPopupMenuListener(PopupMenuListener l)
|
java.awt.Dimension |
getPreferredSize()
|
TreeNode |
getRoot()
Get the root of the tree displayed by the widget. |
TreeNode |
getSelectedNode()
Return the currently selected node of the tree, or null if none. |
boolean |
getShowPreIcons()
Are pre-icons being shown? |
boolean |
isDoubleBuffered()
|
void |
paint(java.awt.Graphics g)
|
protected void |
processActionEvent(java.awt.event.ActionEvent e)
|
protected void |
processMouseEvent(java.awt.event.MouseEvent e)
|
protected void |
processPopupMenuEvent(PopupMenuEvent e)
|
void |
redraw()
Redraw the tree in the off-screen back buffer, then make sure this back buffer is visible. |
void |
removeActionListener(java.awt.event.ActionListener l)
|
void |
removePopupMenuListener(PopupMenuListener l)
|
void |
setFont(java.awt.Font f)
|
void |
setIcons(java.net.URL openDirectoryIconURL,
java.net.URL closeDirectoryIconURL,
int parentLineOffset)
Set the open and close directory icons of this tree to the given icons. |
void |
setRoot(TreeNode root)
Set the root of the tree displayed by the widget. |
void |
setShowNodeIcons(boolean show)
Specifies whether or not to display pre-icons in front of the tree. |
Methods inherited from class java.awt.Canvas |
addNotify |
Methods inherited from class java.awt.Component |
action,
add,
addComponentListener,
addFocusListener,
addInputMethodListener,
addKeyListener,
addMouseListener,
addMouseMotionListener,
addPropertyChangeListener,
addPropertyChangeListener,
bounds,
checkImage,
checkImage,
coalesceEvents,
contains,
contains,
createImage,
createImage,
deliverEvent,
disable,
disableEvents,
dispatchEvent,
doLayout,
enable,
enable,
enableEvents,
enableInputMethods,
firePropertyChange,
getAlignmentX,
getAlignmentY,
getBackground,
getBounds,
getBounds,
getColorModel,
getComponentAt,
getComponentAt,
getComponentOrientation,
getCursor,
getDropTarget,
getFont,
getFontMetrics,
getForeground,
getGraphics,
getHeight,
getInputContext,
getInputMethodRequests,
getLocale,
getLocation,
getLocation,
getLocationOnScreen,
getMaximumSize,
getMinimumSize,
getName,
getParent,
getPeer,
getSize,
getSize,
getToolkit,
getTreeLock,
getWidth,
getX,
getY,
gotFocus,
handleEvent,
hasFocus,
hide,
imageUpdate,
inside,
invalidate,
isDisplayable,
isEnabled,
isFocusTraversable,
isLightweight,
isOpaque,
isShowing,
isValid,
isVisible,
keyDown,
keyUp,
layout,
list,
list,
list,
list,
list,
locate,
location,
lostFocus,
minimumSize,
mouseDown,
mouseDrag,
mouseEnter,
mouseExit,
mouseMove,
mouseUp,
move,
nextFocus,
paintAll,
paramString,
postEvent,
preferredSize,
prepareImage,
prepareImage,
print,
printAll,
processComponentEvent,
processEvent,
processFocusEvent,
processInputMethodEvent,
processKeyEvent,
processMouseMotionEvent,
remove,
removeComponentListener,
removeFocusListener,
removeInputMethodListener,
removeKeyListener,
removeMouseListener,
removeMouseMotionListener,
removeNotify,
removePropertyChangeListener,
removePropertyChangeListener,
repaint,
repaint,
repaint,
repaint,
requestFocus,
reshape,
resize,
resize,
setBackground,
setBounds,
setBounds,
setComponentOrientation,
setCursor,
setDropTarget,
setEnabled,
setForeground,
setLocale,
setLocation,
setLocation,
setName,
setSize,
setSize,
setVisible,
show,
show,
size,
toString,
transferFocus,
update,
validate |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public Tree()
Default constructor. Creates a tree with no directory icons.
public Tree(java.net.URL openDirectoryIconURL, java.net.URL closeDirectoryIconURL, int parentLineOffset)
Create a tree widget that will display the specified open/close directory icons before each directory in the tree. The icons will only be used if both icons can be loaded!
The parentLineOffset specifies by how many pixels the parent connection line should be indented to center under the given directory icons.
Method Detail |
protected void processActionEvent(java.awt.event.ActionEvent e)
public void addActionListener(java.awt.event.ActionListener l)
public void removeActionListener(java.awt.event.ActionListener l)
protected void processPopupMenuEvent(PopupMenuEvent e)
public void addPopupMenuListener(PopupMenuListener l)
public void removePopupMenuListener(PopupMenuListener l)
public void redraw()
Redraw the tree in the off-screen back buffer, then make sure this back buffer is visible.
Make sure you call redraw after programmatic changes to the tree diplayed by the Tree widget!
public void setFont(java.awt.Font f)
public void setIcons(java.net.URL openDirectoryIconURL, java.net.URL closeDirectoryIconURL, int parentLineOffset)
Set the open and close directory icons of this tree to the given icons. Only if both icons can be loaded will they be used in the tree.
The parentLineOffset specifies by how many pixels the parent connection line should be indented to center under the given directory icons.
public void setShowNodeIcons(boolean show)
Specifies whether or not to display pre-icons in front of the tree. If a tree node has an icon it will be displayed at the start of that node's tree line, as a pre-icon.
public boolean getShowPreIcons()
Are pre-icons being shown?
public void setRoot(TreeNode root)
Set the root of the tree displayed by the widget.
public TreeNode getRoot()
Get the root of the tree displayed by the widget.
public TreeNode getSelectedNode()
Return the currently selected node of the tree, or null if none.
protected void processMouseEvent(java.awt.event.MouseEvent e)
public void paint(java.awt.Graphics g)
public boolean isDoubleBuffered()
public java.awt.Dimension getPreferredSize()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |