Package com.portal.ctrl
Class PBreadCrumbs
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.portal.ctrl.PBreadCrumbs
- All Implemented Interfaces:
ActionListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
This component provides a visual trail (in the form of selectable links)
reflecting the pages viewed by the user.
In a GUI where a user can "drill down" from one screen to another, this
component provides a visual cue as to where you are, where you came
from, and a mechanism to get back.
Each time the user drills down, another breadcrumb (link) is added to the trail. The user can then pop back up by clicking on any of those breadcrumbs. Selecting the initial (first) link in the trail will take the user back to the initial screen and cause all links to be removed from the breadcrumb trail.
When a link is selected indicating the user wishes to "pop back", a vetoable property change event is sent out to any registered listeners. If the event is vetoed the selection is ignored and you will remain on the current link.
Each time the user drills down, another breadcrumb (link) is added to the trail. The user can then pop back up by clicking on any of those breadcrumbs. Selecting the initial (first) link in the trail will take the user back to the initial screen and cause all links to be removed from the breadcrumb trail.
When a link is selected indicating the user wishes to "pop back", a vetoable property change event is sent out to any registered listeners. If the event is vetoed the selection is ignored and you will remain on the current link.
- Author:
- kapono
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The vetoable property that is sent out before popping up in the trail when a link is selected.Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Internal listener for link selection eventsvoid
Used to notify the ActionListener that a link was selected in the trailvoid
Adds a link (breadcrumb) to the trail and establishes this link as the current location.void
clear()
Removes all links from the trailboolean
Used to determine if the given link name is contained in the breadcrumb trailvoid
establishLinks
(Enumeration enumElems) Takes the Strings contained in the Enumeration and creates a brand new breadcrumb trail from it.Retrieves the current link taggetLinks()
Retrieves the current links in the trail.getRoot()
Retrieves the base tag for the breadcrumb trail.void
A mechanism to navigate back to the previous link (breadcrumb).void
Remove the listener from link selection notificationboolean
setCurrentLink
(String tag) A mechanism to navigate backwards to the given link (breadcrumb).void
Establishes the base tag for the breadcrumb trail.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, 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, getBaseline, getBaselineResizeBehavior, 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, addImpl, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
LINK_CHANGE
The vetoable property that is sent out before popping up in the trail when a link is selected.- See Also:
-
-
Constructor Details
-
PBreadCrumbs
public PBreadCrumbs()Instantiates the breadcrumb component
-
-
Method Details
-
setRoot
Establishes the base tag for the breadcrumb trail. This should be the tag for the screen that appears initially. The user will not see this tag/link until they drill down since they are not able to use this link for navigation until they have switched to another component.- Parameters:
tag
- The tag for the root link in the trail.
-
getRoot
Retrieves the base tag for the breadcrumb trail.- Returns:
- The base tag for the breadcrumb trail.
-
getCurrentLink
Retrieves the current link tag- Returns:
- The tag for the current link; null if there is no link
-
setCurrentLink
A mechanism to navigate backwards to the given link (breadcrumb). An attempt will be made to locate the given link by traversing backwards up the trail. If the given link is located all links between the current link and the given link will be removed.- Parameters:
tag
- The name/text of the link to locate- Returns:
- true if the move was successful; false otherwise
-
getLinks
Retrieves the current links in the trail. Note that the Enumeration will contain the original text for each link - the separator will be removed.- Returns:
- An Enumeration containing all the links currently in the trail.
-
establishLinks
Takes the Strings contained in the Enumeration and creates a brand new breadcrumb trail from it. Any existing trail is cleared prior to the new trail being created.
This method will verify that the first link in the Enumeration matches the breadcrumb root. If it does not match, this method will throw an IllegalArgumentException.- Throws:
IllegalArgumentException
-
addLink
Adds a link (breadcrumb) to the trail and establishes this link as the current location. The current location is non-selectable and will be presented non-underlined in a different color than the links.- Parameters:
tag
- The text to display in the link
-
addActionListener
Used to notify the ActionListener that a link was selected in the trail- Parameters:
l
- The ActionListener
-
removeActionListener
Remove the listener from link selection notification- Parameters:
l
- The ActionListener
-
moveToPreviousLink
public void moveToPreviousLink()A mechanism to navigate back to the previous link (breadcrumb). If you move back to the root, everything in the breadcrumb trail will be removed. An ActionEvent will be delivered to all listeners indicating the new current link (replicating user selection). -
clear
public void clear()Removes all links from the trail -
contains
Used to determine if the given link name is contained in the breadcrumb trail- Parameters:
tag
- The link to search for- Returns:
- true if the trail contains the given link; false otherwise
-
actionPerformed
Internal listener for link selection events- Specified by:
actionPerformed
in interfaceActionListener
- Parameters:
ae
- The action event
-