JComponentPack 1.5.0

com.zfqjava.swing
Class JSidePane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.zfqjava.swing.JSidePane
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
JSideBar

public class JSidePane
extends JComponent
implements Accessible

JSidePane provides a component to add group panel.

See Also:
ValueAction, Serialized Form

Nested Class Summary
protected  class JSidePane.AccessibleJSidePane
          This class implements accessibility support for the JSidePane class.
 
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
 
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
JSidePane()
          Constructs a JSidePane.
 
Method Summary
 void addGroup(Component comp)
          Adds the group component.
 void addGroup(Component comp, Action action)
          Adds the group componet with the group header action.
 void addGroupAt(Component comp, Action action, int index)
          Adds the group component at the specify index with the group header action.
 void addListSelectionListener(ListSelectionListener listener)
          Adds a listener to the list that's notified each time a change to the selection occurs.
protected  ListSelectionModel createSelectionModel()
          Returns an instance of DefaultListSelectionModel.
protected  Component createTitle(Action a)
          Creates the title component for the specified action.
protected  void fireSelectionValueChanged(int firstIndex, int lastIndex, boolean isAdjusting)
          Notifies JList ListSelectionListeners that the selection model has changed.
 AccessibleContext getAccessibleContext()
          Gets the AccessibleContext associated with this JSidePane.
 Action getActionAt(int index)
          Returns the action at the specify index.
 Component getComponentAt(int index)
          Returns the component at the specify index.
 int getGroupCount()
          Returns the group count.
 int getGroupGap()
          Returns the gap between group.
 ListSelectionListener[] getListSelectionListeners()
          Returns an array of all the ListSelectionListeners added to this JList with addListSelectionListener().
 Component getSelectedComponent()
          Returns the currently selected component for this sidepane.
 int getSelectedIndex()
          Returns the currently selected index for this sidepane.
 int getSelectionMode()
          Returns whether single-item or multiple-item selections are allowed.
 ListSelectionModel getSelectionModel()
          Returns the value of the current selection model.
 Component getTitleAt(int index)
          Returns the title component at the specified index.
 int indexOfAction(Action action)
          Returns the action at the specify index.
 int indexOfComponent(Component comp)
          Returns the index for the specify component.
 int indexOfTitle(Component title)
          Returns the index for the specified title component.
protected  void paintComponent(Graphics g)
           
protected  String paramString()
          Returns a string representation of this JSidePane.
 void removeAllGroup()
          Removes all group component.
 void removeGroup(Component comp)
          Removes the group component.
 void removeGroupAt(int index)
          Removes the group component at the specified index.
 void removeListSelectionListener(ListSelectionListener listener)
          Removes a listener from the list that's notified each time a change to the selection occurs.
 void setActionAt(int index, Action action)
          Sets the action at the specify index.
 void setComponentAt(int index, Component comp)
          Sets the group component at the specify index.
 void setGroupGap(int groupGap)
          Sets the gap between group.
 void setLayout(LayoutManager mgr)
           
 void setSelectedComponent(Component comp)
          Sets the selected component for this sidepane.
 void setSelectedIndex(int index)
          Sets the selected index for this sidepane.
 void setSelectionMode(int selectionMode)
          Determines whether single-item or multiple-item selections are allowed.
 void setSelectionModel(ListSelectionModel selectionModel)
          Sets the selectionModel for the list to a non-null ListSelectionModel implementation.
 void setTitleAt(int index, Component title)
          Sets the title component at the specified index.
 void 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, 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
 

Constructor Detail

JSidePane

public JSidePane()
Constructs a JSidePane.

Method Detail

updateUI

public void updateUI()
Overrides:
updateUI in class JComponent

setGroupGap

public void setGroupGap(int groupGap)
Sets the gap between group.

Parameters:
groupGap - the group gap
See Also:
getGroupGap()

getGroupGap

public int getGroupGap()
Returns the gap between group.

Returns:
the group gap
See Also:
setGroupGap(int)

createSelectionModel

protected ListSelectionModel createSelectionModel()
Returns an instance of DefaultListSelectionModel. This method is used by the constructor to initialize the selectionModel property.

Returns:
the ListSelectionModel used by this JList.
See Also:
setSelectionModel(javax.swing.ListSelectionModel), DefaultListSelectionModel

getSelectionModel

public ListSelectionModel getSelectionModel()
Returns the value of the current selection model. The selection model handles the task of making single selections, selections of contiguous ranges, and non-contiguous selections.

Returns:
the ListSelectionModel that implements list selections
See Also:
setSelectionModel(javax.swing.ListSelectionModel), ListSelectionModel

fireSelectionValueChanged

protected void fireSelectionValueChanged(int firstIndex,
                                         int lastIndex,
                                         boolean isAdjusting)
Notifies JList ListSelectionListeners that the selection model has changed. It's used to forward ListSelectionEvents from the selectionModel to the ListSelectionListeners added directly to the JList.

Parameters:
firstIndex - the first selected index
lastIndex - the last selected index
isAdjusting - true if multiple changes are being made
See Also:
addListSelectionListener(javax.swing.event.ListSelectionListener), removeListSelectionListener(javax.swing.event.ListSelectionListener), EventListenerList

addListSelectionListener

public void addListSelectionListener(ListSelectionListener listener)
Adds a listener to the list that's notified each time a change to the selection occurs. Listeners added directly to the JList will have their ListSelectionEvent.getSource() == this JList (instead of the ListSelectionModel).

Parameters:
listener - the ListSelectionListener to add
See Also:
getSelectionModel(), getListSelectionListeners()

removeListSelectionListener

public void removeListSelectionListener(ListSelectionListener listener)
Removes a listener from the list that's notified each time a change to the selection occurs.

Parameters:
listener - the ListSelectionListener to remove
See Also:
addListSelectionListener(javax.swing.event.ListSelectionListener), getSelectionModel()

getListSelectionListeners

public ListSelectionListener[] getListSelectionListeners()
Returns an array of all the ListSelectionListeners added to this JList with addListSelectionListener().

Returns:
all of the ListSelectionListeners added or an empty array if no listeners have been added
See Also:
addListSelectionListener(javax.swing.event.ListSelectionListener)

setSelectionModel

public void setSelectionModel(ListSelectionModel selectionModel)
Sets the selectionModel for the list to a non-null ListSelectionModel implementation. The selection model handles the task of making single selections, selections of contiguous ranges, and non-contiguous selections.

This is a JavaBeans bound property.

Parameters:
selectionModel - the ListSelectionModel that implements the selections
Throws:
IllegalArgumentException - if selectionModel is null
See Also:
getSelectionModel()

setSelectionMode

public void setSelectionMode(int selectionMode)
Determines whether single-item or multiple-item selections are allowed. The following selectionMode values are allowed:

Parameters:
selectionMode - an integer specifying the type of selections that are permissible
See Also:
getSelectionMode()

getSelectionMode

public int getSelectionMode()
Returns whether single-item or multiple-item selections are allowed.

Returns:
the value of the selectionMode property
See Also:
setSelectionMode(int)

setSelectedIndex

public void setSelectedIndex(int index)
Sets the selected index for this sidepane. 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 sidepane). If a -1 value is specified when the sidepane contains one or more components, then the results will be implementation defined.

Parameters:
index - the index to be selected
Throws:
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 sidepane. Returns -1 if there is no currently selected .

Returns:
the index of the selected component
See Also:
setSelectedIndex(int)

setSelectedComponent

public void setSelectedComponent(Component comp)
Sets the selected component for this sidepane. This will automatically set the selectedIndex to the index corresponding to the specified component.

Throws:
IllegalArgumentException - if component not found in componentbed pane
See Also:
getSelectedComponent()

getSelectedComponent

public Component getSelectedComponent()
Returns the currently selected component for this sidepane. Returns null if there is no currently display card.

Returns:
the component corresponding to the selected component
See Also:
setSelectedComponent(java.awt.Component)

setLayout

public final void setLayout(LayoutManager mgr)
Overrides:
setLayout in class Container

paintComponent

protected void paintComponent(Graphics g)
Overrides:
paintComponent in class JComponent

addGroup

public void addGroup(Component comp)
Adds the group component.

Parameters:
comp - the component to add

addGroup

public void addGroup(Component comp,
                     Action action)
Adds the group componet with the group header action.

Parameters:
comp - the group component
action - the group action

addGroupAt

public void addGroupAt(Component comp,
                       Action action,
                       int index)
Adds the group component at the specify index with the group header action.

Parameters:
comp - the component to add
action - the group action
index - the component index
Throws:
IndexOutOfBoundsException

removeGroupAt

public void removeGroupAt(int index)
Removes the group component at the specified index.

Parameters:
index - the specified group index

removeGroup

public void removeGroup(Component comp)
Removes the group component.

Parameters:
comp - the component to remove

removeAllGroup

public void removeAllGroup()
Removes all group component.


getGroupCount

public int getGroupCount()
Returns the group count.

Returns:
the group count

setComponentAt

public void setComponentAt(int index,
                           Component comp)
Sets the group component at the specify index.

Parameters:
index - the specify index
component - the component
Throws:
NullPointerException - if the comp is null
IndexOutOfBoundsException - if index is out of range (index < 0 || index > group count)

getComponentAt

public Component getComponentAt(int index)
Returns the component at the specify index.

Parameters:
index - the specify index
Returns:
the component at the specify index

indexOfComponent

public int indexOfComponent(Component comp)
Returns the index for the specify component. Return -1 if the comp cannot found.

Parameters:
comp - the specify component
Returns:
the index for the specify component

setActionAt

public void setActionAt(int index,
                        Action action)
Sets the action at the specify index. This action used by group header.

Parameters:
index - the action index
action - the group header action
Throws:
IndexOutOfBoundsException - if index is out of range (index < 0 || index > group count)

getActionAt

public Action getActionAt(int index)
Returns the action at the specify index.

Parameters:
index - the action index
Returns:
the action at the specify index
Throws:
IndexOutOfBoundsException - if index is out of range (index < 0 || index > group count)

indexOfAction

public int indexOfAction(Action action)
Returns the action at the specify index. Return -1 if the action cannot found.

Parameters:
index - the action index
Returns:
the action for the specify component

getTitleAt

public Component getTitleAt(int index)
Returns the title component at the specified index.

Parameters:
index - the title index
Returns:
the title component
Since:
JSidePane 1.1
See Also:
setTitleAt(int, java.awt.Component)

setTitleAt

public void setTitleAt(int index,
                       Component title)
Sets the title component at the specified index.

Parameters:
index - the title index
title - the title component
Throws:
NullPointerException - if the title is null
IndexOutOfBoundsException - if index is out of range (index < 0 || index > group count)
Since:
JSidePane 1.1
See Also:
getTitleAt(int)

indexOfTitle

public int indexOfTitle(Component title)
Returns the index for the specified title component.

Parameters:
title - the title component
Returns:
the title index
Since:
JSidePane 1.1

createTitle

protected Component createTitle(Action a)
Creates the title component for the specified action.

Parameters:
a - the group title action
Returns:
the title component
Since:
JSidePane 1.1

paramString

protected String paramString()
Returns a string representation of this JSidePane. 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 JComponent
Returns:
a string representation of this JSidePane.

getAccessibleContext

public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this JSidePane. For JSidePanes, the AccessibleContext takes the form of an AccessibleJSidePane. A new AccessibleJSidePane instance is created if necessary.

Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in class JComponent
Returns:
an AccessibleJSidePane that serves as the AccessibleContext of this JSidePane

JComponentPack 1.5.0

Send your Feedback
JComponentPack 1.5.0
Copyright © 2001-2007 Extreme Component, Inc. All rights reserved.