diva.gui.toolbox
Class JTreePane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JSplitPane
                  extended by diva.gui.toolbox.JTreePane
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class JTreePane
extends javax.swing.JSplitPane

In the case of a small number of panes, a JTabbedPane or a JTreePane is a good way of organizing them. However, in the case of a large number of frames, both of these metaphors break down. This class is meant to organize a number of frames as elements of a tree. Selecting an element in the tree makes the pane visible. The pane and the tree both share this panel, with the tree on top and the pane on the bottom. The two are separated by a movable divider. Unlike tabbed pane and shade pane, this class cannot easily be indexed by numbers. Hence when interacting with objects in pane, most methods take a title instead of a name. In general, only unique titles will work right. This could be expanded to allow access by the treeModel's indexing by child/number methods.

Version:
$Id: JTreePane.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Steve Neuendorffer
See Also:
JTabbedPane, JShadePane, Serialized Form

Nested Class Summary
private static class JTreePane.Entry
          Holds all the info about each entry.
 
Nested classes/interfaces inherited from class javax.swing.JSplitPane
javax.swing.JSplitPane.AccessibleJSplitPane
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  javax.swing.JPanel _defaultPanel
          The panel that is used when the component gets set to null.
private  javax.swing.JScrollPane _scrollPane
          The ScrollPane around the tree.
private  java.awt.Dimension _scrollPaneSize
          The preferred size of the scrollpane.
private  java.lang.String _selectedTitle
          The selected title.
private  javax.swing.JTree _tree
          The Tree.
 
Fields inherited from class javax.swing.JSplitPane
BOTTOM, CONTINUOUS_LAYOUT_PROPERTY, continuousLayout, DIVIDER, DIVIDER_LOCATION_PROPERTY, DIVIDER_SIZE_PROPERTY, dividerSize, HORIZONTAL_SPLIT, LAST_DIVIDER_LOCATION_PROPERTY, lastDividerLocation, LEFT, leftComponent, ONE_TOUCH_EXPANDABLE_PROPERTY, oneTouchExpandable, orientation, ORIENTATION_PROPERTY, RESIZE_WEIGHT_PROPERTY, RIGHT, rightComponent, TOP, VERTICAL_SPLIT
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JTreePane()
           
JTreePane(java.lang.String name)
          Construct an empty instance of the Tree pane.
 
Method Summary
private  JTreePane.Entry _findEntry(java.lang.String title)
          Return the entry with the given title, or null if no Entry is found with the given title.
private  javax.swing.tree.DefaultMutableTreeNode _findNode(java.lang.String title)
          Return the node with the given title.
 void addEntry(java.lang.String parent, java.lang.String title, javax.swing.Icon icon, javax.swing.JComponent entry)
          Adds a component represented by a title and/or icon, either of which can be null.
 void addEntry(java.lang.String parent, java.lang.String title, javax.swing.Icon icon, javax.swing.JComponent entry, java.lang.String tip)
          Adds a component and tooltip represented by a title and/or icon, either of which can be null.
 void addEntry(java.lang.String parent, java.lang.String title, javax.swing.JComponent entry)
          Adds a component represented by a title button with no icon.
 javax.swing.JComponent getComponentAt(java.lang.String title)
          Returns the component at the given index.
 javax.swing.Icon getDisabledIconAt(java.lang.String title)
          Returns the tab disabled icon at the given index.
 javax.swing.Icon getIconAt(java.lang.String title)
          Returns the tab icon at the given index.
 java.lang.String getSelectedTitle()
          Return the selectedString.
 javax.swing.JSplitPane getSplitPane()
          Returns the split pane object.
 javax.swing.JTree getTree()
          Returns the tree object.
 void insertEntry(java.lang.String parent, java.lang.String title, javax.swing.Icon icon, javax.swing.JComponent component, java.lang.String tip)
          Insert a entry with the given title/icon/component/tip at the specified index.
 boolean isEnabledAt(java.lang.String title)
          Returns whether or not the tab at the given index is currently enabled.
static void main(java.lang.String[] argv)
           
protected  void refresh()
          Refresh the layout.
 void removeAll()
          Remove all of the entrys.
 void removeEntry(java.lang.String title)
          Remove the entry at the given index.
 void setDisabledIconAt(java.lang.String title, javax.swing.Icon icon)
          Set the disabled icon for the button at the given index.
 void setEnabledAt(java.lang.String title, boolean enabled)
          Set the enabledness of the entry at the given index.
 void setIconAt(java.lang.String title, javax.swing.Icon icon)
          Set the disabled icon for the button at the given index.
 void setSelectedTitle(java.lang.String title)
          Sets the selected index for this entry pane and causes the pane to refresh its display to show the selected pane's component.
 void setTitleAt(java.lang.String title, java.lang.String newTitle)
          Set the title string at the given index.
 
Methods inherited from class javax.swing.JSplitPane
addImpl, getAccessibleContext, getBottomComponent, getDividerLocation, getDividerSize, getLastDividerLocation, getLeftComponent, getMaximumDividerLocation, getMinimumDividerLocation, getOrientation, getResizeWeight, getRightComponent, getTopComponent, getUI, getUIClassID, isContinuousLayout, isOneTouchExpandable, isValidateRoot, paintChildren, paramString, remove, remove, resetToPreferredSizes, setBottomComponent, setContinuousLayout, setDividerLocation, setDividerLocation, setDividerSize, setLastDividerLocation, setLeftComponent, setOneTouchExpandable, setOrientation, setResizeWeight, setRightComponent, setTopComponent, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_selectedTitle

private java.lang.String _selectedTitle
The selected title.


_defaultPanel

private javax.swing.JPanel _defaultPanel
The panel that is used when the component gets set to null.


_tree

private javax.swing.JTree _tree
The Tree.


_scrollPane

private javax.swing.JScrollPane _scrollPane
The ScrollPane around the tree.


_scrollPaneSize

private java.awt.Dimension _scrollPaneSize
The preferred size of the scrollpane. This is required because the splitpane doesn't remember it's size if we change the component that is in it, unless we give it a preferred size.

Constructor Detail

JTreePane

public JTreePane()

JTreePane

public JTreePane(java.lang.String name)
Construct an empty instance of the Tree pane.

Method Detail

addEntry

public void addEntry(java.lang.String parent,
                     java.lang.String title,
                     javax.swing.JComponent entry)
Adds a component represented by a title button with no icon. Cover method for insertEntry().


addEntry

public void addEntry(java.lang.String parent,
                     java.lang.String title,
                     javax.swing.Icon icon,
                     javax.swing.JComponent entry)
Adds a component represented by a title and/or icon, either of which can be null. Cover method for insertEntry().


addEntry

public void addEntry(java.lang.String parent,
                     java.lang.String title,
                     javax.swing.Icon icon,
                     javax.swing.JComponent entry,
                     java.lang.String tip)
Adds a component and tooltip represented by a title and/or icon, either of which can be null. Cover method for insertEntry().


getSelectedTitle

public java.lang.String getSelectedTitle()
Return the selectedString.


getIconAt

public javax.swing.Icon getIconAt(java.lang.String title)
Returns the tab icon at the given index.

See Also:
setIconAt(java.lang.String, javax.swing.Icon)

getDisabledIconAt

public javax.swing.Icon getDisabledIconAt(java.lang.String title)
Returns the tab disabled icon at the given index.

See Also:
setDisabledIconAt(java.lang.String, javax.swing.Icon)

getTree

public javax.swing.JTree getTree()
Returns the tree object.


getSplitPane

public javax.swing.JSplitPane getSplitPane()
Returns the split pane object.


isEnabledAt

public boolean isEnabledAt(java.lang.String title)
Returns whether or not the tab at the given index is currently enabled.

See Also:
setEnabledAt(java.lang.String, boolean)

getComponentAt

public javax.swing.JComponent getComponentAt(java.lang.String title)
Returns the component at the given index.


insertEntry

public void insertEntry(java.lang.String parent,
                        java.lang.String title,
                        javax.swing.Icon icon,
                        javax.swing.JComponent component,
                        java.lang.String tip)
Insert a entry with the given title/icon/component/tip at the specified index. Either the icon can be null, but the title must be specified.


refresh

protected void refresh()
Refresh the layout.


removeAll

public void removeAll()
Remove all of the entrys.

Overrides:
removeAll in class javax.swing.JSplitPane

removeEntry

public void removeEntry(java.lang.String title)
Remove the entry at the given index.


setDisabledIconAt

public void setDisabledIconAt(java.lang.String title,
                              javax.swing.Icon icon)
Set the disabled icon for the button at the given index.


setEnabledAt

public void setEnabledAt(java.lang.String title,
                         boolean enabled)
Set the enabledness of the entry at the given index.


setIconAt

public void setIconAt(java.lang.String title,
                      javax.swing.Icon icon)
Set the disabled icon for the button at the given index.


setSelectedTitle

public void setSelectedTitle(java.lang.String title)
Sets the selected index for this entry pane and causes the pane to refresh its display to show the selected pane's component.


setTitleAt

public void setTitleAt(java.lang.String title,
                       java.lang.String newTitle)
Set the title string at the given index.


_findEntry

private JTreePane.Entry _findEntry(java.lang.String title)
Return the entry with the given title, or null if no Entry is found with the given title.


_findNode

private javax.swing.tree.DefaultMutableTreeNode _findNode(java.lang.String title)
Return the node with the given title. If the title is null, then return the root node. If the node is not found, then return null.


main

public static void main(java.lang.String[] argv)