org.tbee.swing.cardlayout
Class CardLayoutNavigator

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.tbee.swing.cardlayout.CardLayoutNavigator
All Implemented Interfaces:
ActionListener, ContainerListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CardChangedListener, CardChangeListener

public class CardLayoutNavigator
extends JPanel
implements ActionListener, ContainerListener, CardChangeListener

This class examines a container with the CardLayout and shows a button for each component. Clicking on the button will show that component (basically this is ver similar to a JTabbedPanem however the navigator is disconnected). If changes occur in the container (components are added or removed) it will be updated, because it listens to container events. TODO: optimize the number of times populateButtons is called.

Version:
$Revision: 1.37 $
See Also:
Serialized Form

Nested Class Summary
static class CardLayoutNavigator.ORIENTATION
           
 
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
static String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
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
CardLayoutNavigator(Container container)
          TODO: provide good default images
CardLayoutNavigator(Container container, Icon defaultCurrentlyVisibleIcon, Icon defaultHiddenImage)
           
 
Method Summary
 void actionPerformed(ActionEvent e)
           
 void cardChanged(CardChangeEvent e)
           
 void cardChanging(CardChangeEvent e)
           
 void componentAdded(ContainerEvent e)
           
 void componentRemoved(ContainerEvent e)
           
 Container getContainer()
          Container
 CardLayout getContainerLayout()
           
 Icon getDefaultHiddenIcon()
          default hidden icon
 Icon getDefaultVisibleIcon()
          default visible icon
 Icon getHiddenIcon(Component component)
          per panel hidden button
 Icon getHiddenIcon(String name)
           
 CardLayoutNavigator.ORIENTATION getOrientation()
          Orientation
 Icon getVisibleButton(String name)
           
 Icon getVisibleIcon(Component component)
          per panel visible button
 void highlight(Component component)
           
 void highlight(Component component, String name)
           
 void highlight(String name)
           
 void removeHiddenIcon(Component component)
           
 void removeHiddenIcon(String name)
           
 void removeVisibleIcon(Component component)
           
 void removeVisibleIcon(String name)
           
 void setButtonsAlignmentX(float alignment)
          For aligning inside a BoxLayout When BoxLayout is vertical, 0.0 aligns left and 1.0 aligns right
 void setButtonsAlignmentY(float alignment)
          For aligning inside a BoxLayout When BoxLayet is horizontal, 0.0 aligns top and 1.0 aligns bottom
 void setContainer(Container container)
           
 void setDefaultHiddenIcon(Icon value)
           
 void setDefaultVisibleIcon(Icon value)
           
 void setHiddenIcon(Component component, Icon value)
           
 void setHiddenIcon(String name, Icon value)
           
 void setOrientation(CardLayoutNavigator.ORIENTATION value)
           
 void setVisibleIcon(Component component, Icon value)
           
 void setVisibleIcon(String name, Icon value)
           
 JPanel wrapInCompoundPanel(String borderLayoutOrientation)
          Quickly wrap the container and myself in a panel with BorderLayout
 
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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, 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

SOURCECODE_VERSION

public static final String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values
Constructor Detail

CardLayoutNavigator

public CardLayoutNavigator(Container container)
TODO: provide good default images

Parameters:
container -

CardLayoutNavigator

public CardLayoutNavigator(Container container,
                           Icon defaultCurrentlyVisibleIcon,
                           Icon defaultHiddenImage)
Parameters:
container -
defaultCurrentlyVisibleIcon -
defaultHiddenImage -
Method Detail

getContainer

public Container getContainer()
Container


setContainer

public void setContainer(Container container)

getContainerLayout

public CardLayout getContainerLayout()

getDefaultVisibleIcon

public Icon getDefaultVisibleIcon()
default visible icon


setDefaultVisibleIcon

public void setDefaultVisibleIcon(Icon value)

getDefaultHiddenIcon

public Icon getDefaultHiddenIcon()
default hidden icon


setDefaultHiddenIcon

public void setDefaultHiddenIcon(Icon value)

getVisibleIcon

public Icon getVisibleIcon(Component component)
per panel visible button


setVisibleIcon

public void setVisibleIcon(Component component,
                           Icon value)

removeVisibleIcon

public void removeVisibleIcon(Component component)

getVisibleButton

public Icon getVisibleButton(String name)

setVisibleIcon

public void setVisibleIcon(String name,
                           Icon value)

removeVisibleIcon

public void removeVisibleIcon(String name)

getHiddenIcon

public Icon getHiddenIcon(Component component)
per panel hidden button


setHiddenIcon

public void setHiddenIcon(Component component,
                          Icon value)

removeHiddenIcon

public void removeHiddenIcon(Component component)

getHiddenIcon

public Icon getHiddenIcon(String name)

setHiddenIcon

public void setHiddenIcon(String name,
                          Icon value)

removeHiddenIcon

public void removeHiddenIcon(String name)

getOrientation

public CardLayoutNavigator.ORIENTATION getOrientation()
Orientation


setOrientation

public void setOrientation(CardLayoutNavigator.ORIENTATION value)

componentAdded

public void componentAdded(ContainerEvent e)
Specified by:
componentAdded in interface ContainerListener

componentRemoved

public void componentRemoved(ContainerEvent e)
Specified by:
componentRemoved in interface ContainerListener

cardChanged

public void cardChanged(CardChangeEvent e)
Specified by:
cardChanged in interface CardChangedListener

cardChanging

public void cardChanging(CardChangeEvent e)
Specified by:
cardChanging in interface CardChangeListener

setButtonsAlignmentX

public void setButtonsAlignmentX(float alignment)
For aligning inside a BoxLayout When BoxLayout is vertical, 0.0 aligns left and 1.0 aligns right

Parameters:
alignment -

setButtonsAlignmentY

public void setButtonsAlignmentY(float alignment)
For aligning inside a BoxLayout When BoxLayet is horizontal, 0.0 aligns top and 1.0 aligns bottom

Parameters:
alignment -

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener
See Also:
ActionListener.actionPerformed(java.awt.event.ActionEvent)

highlight

public void highlight(String name)
Parameters:
name -

highlight

public void highlight(Component component)
Parameters:
component -

highlight

public void highlight(Component component,
                      String name)
Parameters:
component -
name -

wrapInCompoundPanel

public JPanel wrapInCompoundPanel(String borderLayoutOrientation)
Quickly wrap the container and myself in a panel with BorderLayout

Parameters:
borderLayoutOrientation -


Copyright © 2012 KnowledgePlaza. All Rights Reserved.