com.zfqjava.swing
Class JCardPane

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--com.zfqjava.swing.JCardPane
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class JCardPane
extends javax.swing.JComponent
implements javax.accessibility.Accessible

JCardPane provides a multiple card panel based on CardLayout2.

See Also:
Serialized Form

Inner Class Summary
protected  class JCardPane.AccessibleJCardPane
          This class implements accessibility support for the JCardPane class.
protected  class JCardPane.ModelListener
          We pass ModelChanged events along to the listeners with the cardpane (instead of the model itself) as the event source.
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
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
JCardPane()
          Constructs a JCardPane.
 
Method Summary
 void addChangeListener(javax.swing.event.ChangeListener l)
          Adds a ChangeListener to this cardpane.
protected  void addImpl(java.awt.Component comp, java.lang.Object constraints, int index)
           
protected  javax.swing.event.ChangeListener createChangeListener()
          Subclasses that want to handle ChangeEvents differently can override this to return a subclass of ModelListener or another ChangeListener implementation.
protected  void fireStateChanged()
          Sends a ChangeEvent, whose source is this cardpane, to each listener.
 javax.accessibility.AccessibleContext getAccessibleContext()
          Gets the AccessibleContext associated with this JCardPane.
 javax.swing.event.ChangeListener[] getChangeListeners()
          Returns an array of all the ChangeListeners added to this JCardpane with addChangeListener.
 java.awt.Component getSelectedComponent()
          Returns the currently selected component for this cardpane.
 int getSelectedIndex()
          Returns the currently selected index for this cardpane.
 javax.swing.SingleSelectionModel getSelectionModel()
          Returns the selectionModel associated with this cardpane.
 int indexOfComponent(java.awt.Component comp)
          Gets the component index in this container.
protected  java.lang.String paramString()
          Returns a string representation of this JCardPane.
 void remove(int index)
           
 void removeAll()
           
 void removeChangeListener(javax.swing.event.ChangeListener l)
          Removes a ChangeListener from this cardpane.
 void setSelectedComponent(java.awt.Component comp)
          Sets the selected component for this cardpane.
 void setSelectedIndex(int index)
          Sets the selected index for this cardpane.
 void setSelectionModel(javax.swing.SingleSelectionModel selectionModel)
          Sets the selectionModel to be used with this cardpane.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getUIClassID, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JCardPane

public JCardPane()
Constructs a JCardPane.
Method Detail

addImpl

protected void addImpl(java.awt.Component comp,
                       java.lang.Object constraints,
                       int index)
Overrides:
addImpl in class java.awt.Container

remove

public void remove(int index)
Overrides:
remove in class java.awt.Container

removeAll

public void removeAll()
Overrides:
removeAll in class java.awt.Container

createChangeListener

protected javax.swing.event.ChangeListener createChangeListener()
Subclasses that want to handle ChangeEvents differently can override this to return a subclass of ModelListener or another ChangeListener implementation.
See Also:
fireStateChanged()

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l)
Adds a ChangeListener to this cardpane.
Parameters:
l - the ChangeListener to add
See Also:
fireStateChanged(), removeChangeListener(javax.swing.event.ChangeListener)

removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener l)
Removes a ChangeListener from this cardpane.
Parameters:
l - the ChangeListener to remove
See Also:
fireStateChanged(), addChangeListener(javax.swing.event.ChangeListener)

getChangeListeners

public javax.swing.event.ChangeListener[] getChangeListeners()
Returns an array of all the ChangeListeners added to this JCardpane with addChangeListener.
Returns:
all of the ChangeListeners added or an empty array if no listeners have been added

fireStateChanged

protected void fireStateChanged()
Sends a ChangeEvent, whose source is this cardpane, to each listener. This method method is called each time a ChangeEvent is received from the model.
See Also:
addChangeListener(javax.swing.event.ChangeListener), EventListenerList

getSelectionModel

public javax.swing.SingleSelectionModel getSelectionModel()
Returns the selectionModel associated with this cardpane.
See Also:
setSelectionModel(javax.swing.SingleSelectionModel)

setSelectionModel

public void setSelectionModel(javax.swing.SingleSelectionModel selectionModel)
Sets the selectionModel to be used with this cardpane.
Parameters:
selectionModel - the selectionModel to be used
See Also:
getSelectionModel()

setSelectedIndex

public void setSelectedIndex(int index)
Sets the selected index for this cardpane. The index must be a valid component index or -1, which indicates that no component should be selected (can also be used when there are no components in the cardpane). If a -1 value is specified when the cardpane contains one or more components, then the results will be implementation defined.
Parameters:
index - the index to be selected
Throws:
java.lang.IndexOutOfBoundsException - if index is out of range (index < -1 || index >= component count)
See Also:
getSelectedIndex(), SingleSelectionModel.setSelectedIndex(int)

getSelectedIndex

public int getSelectedIndex()
Returns the currently selected index for this cardpane. Returns -1 if there is no currently selected .
Returns:
the index of the selected component
See Also:
setSelectedIndex(int)

setSelectedComponent

public void setSelectedComponent(java.awt.Component comp)
Sets the selected component for this cardpane. This will automatically set the selectedIndex to the index corresponding to the specified component.
Throws:
java.lang.IllegalArgumentException - if component not found in componentbed pane
See Also:
getSelectedComponent()

indexOfComponent

public int indexOfComponent(java.awt.Component comp)
Gets the component index in this container.
Parameters:
comp - the component
Returns:
the component index, or -1 if no such component

getSelectedComponent

public java.awt.Component getSelectedComponent()
Returns the currently selected component for this cardpane. Returns null if there is no currently display card.
Returns:
the component corresponding to the selected component
See Also:
setSelectedComponent(java.awt.Component)

paramString

protected java.lang.String paramString()
Returns a string representation of this JCardPane. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.
Overrides:
paramString in class javax.swing.JComponent
Returns:
a string representation of this JCardPane.

getAccessibleContext

public javax.accessibility.AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this JCardPane. For JCardPanes, the AccessibleContext takes the form of an AccessibleJCardPane. A new AccessibleJCardPane instance is created if necessary.
Specified by:
getAccessibleContext in interface javax.accessibility.Accessible
Overrides:
getAccessibleContext in class javax.swing.JComponent
Returns:
an AccessibleJCardPane that serves as the AccessibleContext of this JCardPane


Copyright © 2001-2003 Extreme Component, Inc. All rights reserved.