com.google.gwt.user.client.ui
Class Tree

java.lang.Object
  extended bycom.google.gwt.user.client.ui.UIObject
      extended bycom.google.gwt.user.client.ui.Widget
          extended bycom.google.gwt.user.client.ui.Tree
All Implemented Interfaces:
EventListener, SourcesTreeEvents

public class Tree
extends Widget
implements SourcesTreeEvents

A standard hierarchical tree widget. The tree contains a hierarchy of TreeItems that the user can open, close, and select.

CSS Style Rules

Example

code


Field Summary
 
Fields inherited from class java.lang.Object
typeId, typeName
 
Constructor Summary
Tree()
          Constructs an empty tree.
 
Method Summary
 void addFocusListener(FocusListener listener)
           
 TreeItem addItem(String itemText)
          Adds a simple tree item containing the specified text.
 void addItem(TreeItem item)
          Adds an item to the root level of this tree.
 void addKeyboardListener(KeyboardListener listener)
           
 void addMouseListener(MouseListener listener)
           
 void addTreeListener(TreeListener listener)
          Adds a listener interface to receive tree events.
 void ensureSelectedItemVisible()
          Ensures that the currently-selected item is visible, opening its parents and scrolling the tree as necessary.
 String getImageBase()
          Gets this tree's default image package.
 TreeItem getItem(int index)
          Gets the top-level tree item at the specified index.
 int getItemCount()
          Gets the number of items contained at the root of this tree.
 TreeItem getSelectedItem()
          Gets the currently selected item.
 int getTabIndex()
           
 void onBrowserEvent(Event event)
          Fired whenever a browser event is received.
protected  void onLoad()
          This method is called when the widget becomes attached to the browser's document.
 void removeFocusListener(FocusListener listener)
           
 void removeItem(TreeItem item)
          Removes an item from the root level of this tree.
 void removeItems()
          Removes all items from the root level of this tree.
 void removeKeyboardListener(KeyboardListener listener)
           
 void removeTreeListener(TreeListener listener)
          Removes a previously added listener interface.
 void setAccessKey(char key)
           
 void setFocus(boolean focus)
           
 void setImageBase(String baseUrl)
          Sets the base URL under which this tree will find its default images.
 void setSelectedItem(TreeItem item)
          Selects a specified item.
 void setSelectedItem(TreeItem item, boolean fireEvents)
          Selects a specified item.
 void setTabIndex(int index)
           
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
getParent, isAttached, onAttach, onDetach
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleName, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleName, isVisible, isVisible, removeStyleName, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
equals, finalize, hashCode
 

Constructor Detail

Tree

public Tree()
Constructs an empty tree.

Method Detail

addFocusListener

public void addFocusListener(FocusListener listener)

addItem

public TreeItem addItem(String itemText)
Adds a simple tree item containing the specified text.

Parameters:
itemText - the text of the item to be added
Returns:
the item that was added

addItem

public void addItem(TreeItem item)
Adds an item to the root level of this tree.

Parameters:
item - the item to be added

addKeyboardListener

public void addKeyboardListener(KeyboardListener listener)

addTreeListener

public void addTreeListener(TreeListener listener)
Description copied from interface: SourcesTreeEvents
Adds a listener interface to receive tree events.

Specified by:
addTreeListener in interface SourcesTreeEvents
Parameters:
listener - the listener interface to add

ensureSelectedItemVisible

public void ensureSelectedItemVisible()
Ensures that the currently-selected item is visible, opening its parents and scrolling the tree as necessary.


getImageBase

public String getImageBase()
Gets this tree's default image package.

Returns:
the tree's image package
See Also:
setImageBase(java.lang.String)

getItem

public TreeItem getItem(int index)
Gets the top-level tree item at the specified index.

Parameters:
index - the index to be retrieved
Returns:
the item at that index

getItemCount

public int getItemCount()
Gets the number of items contained at the root of this tree.

Returns:
this tree's item count

getSelectedItem

public TreeItem getSelectedItem()
Gets the currently selected item.

Returns:
the selected item

getTabIndex

public int getTabIndex()

onBrowserEvent

public void onBrowserEvent(Event event)
Description copied from interface: EventListener
Fired whenever a browser event is received.

Specified by:
onBrowserEvent in interface EventListener
Overrides:
onBrowserEvent in class Widget

removeFocusListener

public void removeFocusListener(FocusListener listener)

removeItem

public void removeItem(TreeItem item)
Removes an item from the root level of this tree.

Parameters:
item - the item to be removed

removeItems

public void removeItems()
Removes all items from the root level of this tree.


removeKeyboardListener

public void removeKeyboardListener(KeyboardListener listener)

removeTreeListener

public void removeTreeListener(TreeListener listener)
Description copied from interface: SourcesTreeEvents
Removes a previously added listener interface.

Specified by:
removeTreeListener in interface SourcesTreeEvents
Parameters:
listener - the listener interface to remove

setAccessKey

public void setAccessKey(char key)

setFocus

public void setFocus(boolean focus)

setImageBase

public void setImageBase(String baseUrl)
Sets the base URL under which this tree will find its default images. These images must be named "tree_white.gif", "tree_open.gif", and "tree_closed.gif".


setSelectedItem

public void setSelectedItem(TreeItem item)
Selects a specified item.

Parameters:
item - the item to be selected, or null to unselect all items

setSelectedItem

public void setSelectedItem(TreeItem item,
                            boolean fireEvents)
Selects a specified item.

Parameters:
item - the item to be selected, or null to unselect all items
fireEvents - true to allow selection events to be fired

setTabIndex

public void setTabIndex(int index)

onLoad

protected void onLoad()
Description copied from class: Widget
This method is called when the widget becomes attached to the browser's document.

Overrides:
onLoad in class Widget

addMouseListener

public void addMouseListener(MouseListener listener)


This javadoc distribution was not produced by Google. The official documentation is here.