Class JXTaskPane
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- org.jdesktop.swingx.JXTaskPane
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
,JXCollapsiblePane.CollapsiblePaneContainer
,Mnemonicable
@JavaBean public class JXTaskPane extends javax.swing.JPanel implements JXCollapsiblePane.CollapsiblePaneContainer, Mnemonicable
JXTaskPane
is a container for tasks and other arbitrary components.Several
JXTaskPane
s are usually grouped together within aJXTaskPaneContainer
. However it is not mandatory to use a JXTaskPaneContainer as the parent for JXTaskPane. The JXTaskPane can be added to any other container. SeeJXTaskPaneContainer
to understand the benefits of using it as the parent container.JXTaskPane
provides control to expand and collapse the content area in order to show or hide the task list. It can have anicon
, atitle
and can be marked asspecial
. Marking aJXTaskPane
asspecial
(setSpecial(boolean)
is only a hint for the pluggable UI which will usually paint it differently (by example by using another color for the border of the pane).When the JXTaskPane is expanded or collapsed, it will be animated with a fade effect. The animated can be disabled on a per component basis through
setAnimated(boolean)
. To disable the animation for all newly createdJXTaskPane
, use the UIManager property:UIManager.put("TaskPane.animate", Boolean.FALSE);
.Example:
JXFrame frame = new JXFrame(); // a container to put all JXTaskPane together JXTaskPaneContainer taskPaneContainer = new JXTaskPaneContainer(); // create a first taskPane with common actions JXTaskPane actionPane = new JXTaskPane(); actionPane.setTitle("Files and Folders"); actionPane.setSpecial(true); // actions can be added, a hyperlink will be created Action renameSelectedFile = createRenameFileAction(); actionPane.add(renameSelectedFile); actionPane.add(createDeleteFileAction()); // add this taskPane to the taskPaneContainer taskPaneContainer.add(actionPane); // create another taskPane, it will show details of the selected file JXTaskPane details = new JXTaskPane(); details.setTitle("Details"); // add standard components to the details taskPane JLabel searchLabel = new JLabel("Search:"); JTextField searchField = new JTextField(""); details.add(searchLabel); details.add(searchField); taskPaneContainer.add(details); // put the action list on the left frame.add(taskPaneContainer, BorderLayout.EAST); // and a file browser in the middle frame.add(fileBrowser, BorderLayout.CENTER); frame.pack(); frame.setVisible(true);
- See Also:
JXTaskPaneContainer
,JXCollapsiblePane
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ANIMATED_CHANGED_KEY
Used when generating PropertyChangeEvents for the "animated" propertyprivate JXCollapsiblePane
collapsePane
private javax.swing.Icon
icon
static java.lang.String
ICON_CHANGED_KEY
Used when generating PropertyChangeEvents for the "icon" propertyprivate int
mnemonic
private int
mnemonicIndex
static java.lang.String
SCROLL_ON_EXPAND_CHANGED_KEY
Used when generating PropertyChangeEvents for the "scrollOnExpand" propertyprivate boolean
scrollOnExpand
private boolean
special
static java.lang.String
SPECIAL_CHANGED_KEY
Used when generating PropertyChangeEvents for the "special" propertyprivate java.lang.String
title
static java.lang.String
TITLE_CHANGED_KEY
Used when generating PropertyChangeEvents for the "title" propertystatic java.lang.String
uiClassID
JXTaskPane pluggable UI key swingx/TaskPaneUI-
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
-
-
Constructor Summary
Constructors Constructor Description JXTaskPane()
Creates a new emptyJXTaskPane
.JXTaskPane(java.lang.String title)
Creates a new task pane with the specified title.JXTaskPane(java.lang.String title, javax.swing.Icon icon)
Creates a new task pane with the specified title and icon.JXTaskPane(javax.swing.Icon icon)
Creates a new task pane with the specified icon.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.Component
add(javax.swing.Action action)
Adds an action to thisJXTaskPane
.protected void
addImpl(java.awt.Component comp, java.lang.Object constraints, int index)
Overridden to redirect call to the content pane.java.awt.Container
getContentPane()
Returns the contentPane object for this JXTaskPane.int
getDisplayedMnemonicIndex()
Returns the character, as an index, that the look and feel should provide decoration for as representing the mnemonic character.javax.swing.Icon
getIcon()
Returns the icon currently displayed in the border of this pane.int
getMnemonic()
Returns the keyboard mnemonic for this component.java.lang.String
getTitle()
Returns the title currently displayed in the border of this pane.java.lang.String
getUIClassID()
Returns the name of the L&F class that renders this component.java.awt.Container
getValidatingContainer()
boolean
isAnimated()
Returns true if this task pane is animated during expand/collapse transition.boolean
isCollapsed()
Returns the collapsed state of this task pane.boolean
isScrollOnExpand()
Should this group scroll to be visible after this group was expanded.boolean
isSpecial()
Returns true if this pane is "special".protected java.lang.String
paramString()
void
remove(int index)
Overridden to redirect call to the content pane.void
remove(java.awt.Component comp)
Overridden to redirect call to the content panevoid
removeAll()
Overridden to redirect call to the content pane.void
setAnimated(boolean animated)
Enables or disables animation during expand/collapse transition.void
setCollapsed(boolean collapsed)
Expands or collapses this group.void
setDisplayedMnemonicIndex(int index)
Provides a hint to the look and feel as to which character in the text should be decorated to represent the mnemonic.void
setIcon(javax.swing.Icon icon)
Sets the icon to be displayed in the border of this pane.void
setLayout(java.awt.LayoutManager mgr)
Overridden to redirect call to the content pane.void
setMnemonic(int mnemonic)
Sets the keyboard mnemonic on this component.void
setScrollOnExpand(boolean scrollOnExpand)
Should this group be scrolled to be visible on expand.void
setSpecial(boolean special)
Sets this pane to be "special" or not.void
setTitle(java.lang.String title)
Sets the title to be displayed in the border of this pane.void
setUI(TaskPaneUI ui)
Sets the L&F object that renders this component.private void
updateDisplayedMnemonicIndex(java.lang.String text, int mnemonic)
Update the displayedMnemonicIndex property.void
updateUI()
Notification from theUIManager
that the L&F has changed.-
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, 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, 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 Detail
-
uiClassID
public static final java.lang.String uiClassID
JXTaskPane pluggable UI key swingx/TaskPaneUI- See Also:
- Constant Field Values
-
SCROLL_ON_EXPAND_CHANGED_KEY
public static final java.lang.String SCROLL_ON_EXPAND_CHANGED_KEY
Used when generating PropertyChangeEvents for the "scrollOnExpand" property- See Also:
- Constant Field Values
-
TITLE_CHANGED_KEY
public static final java.lang.String TITLE_CHANGED_KEY
Used when generating PropertyChangeEvents for the "title" property- See Also:
- Constant Field Values
-
ICON_CHANGED_KEY
public static final java.lang.String ICON_CHANGED_KEY
Used when generating PropertyChangeEvents for the "icon" property- See Also:
- Constant Field Values
-
SPECIAL_CHANGED_KEY
public static final java.lang.String SPECIAL_CHANGED_KEY
Used when generating PropertyChangeEvents for the "special" property- See Also:
- Constant Field Values
-
ANIMATED_CHANGED_KEY
public static final java.lang.String ANIMATED_CHANGED_KEY
Used when generating PropertyChangeEvents for the "animated" property- See Also:
- Constant Field Values
-
title
private java.lang.String title
-
icon
private javax.swing.Icon icon
-
special
private boolean special
-
scrollOnExpand
private boolean scrollOnExpand
-
mnemonic
private int mnemonic
-
mnemonicIndex
private int mnemonicIndex
-
collapsePane
private JXCollapsiblePane collapsePane
-
-
Constructor Detail
-
JXTaskPane
public JXTaskPane()
Creates a new emptyJXTaskPane
.
-
JXTaskPane
public JXTaskPane(java.lang.String title)
Creates a new task pane with the specified title.- Parameters:
title
- the title to use
-
JXTaskPane
public JXTaskPane(javax.swing.Icon icon)
Creates a new task pane with the specified icon.- Parameters:
icon
- the icon to use
-
JXTaskPane
public JXTaskPane(java.lang.String title, javax.swing.Icon icon)
Creates a new task pane with the specified title and icon.- Parameters:
title
- the title to useicon
- the icon to use
-
-
Method Detail
-
getContentPane
public java.awt.Container getContentPane()
Returns the contentPane object for this JXTaskPane.- Returns:
- the contentPane property
-
updateUI
public void updateUI()
Notification from theUIManager
that the L&F has changed. Replaces the current UI object with the latest version from theUIManager
.- Overrides:
updateUI
in classjavax.swing.JPanel
- See Also:
JComponent.updateUI()
-
setUI
public void setUI(TaskPaneUI ui)
Sets the L&F object that renders this component.- Parameters:
ui
- theTaskPaneUI
L&F object- See Also:
UIDefaults.getUI(javax.swing.JComponent)
-
getUIClassID
public java.lang.String getUIClassID()
Returns the name of the L&F class that renders this component.- Overrides:
getUIClassID
in classjavax.swing.JPanel
- Returns:
- the string
uiClassID
- See Also:
JComponent.getUIClassID()
,UIDefaults.getUI(javax.swing.JComponent)
-
getTitle
public java.lang.String getTitle()
Returns the title currently displayed in the border of this pane.- Returns:
- the title currently displayed in the border of this pane
-
setTitle
public void setTitle(java.lang.String title)
Sets the title to be displayed in the border of this pane.- Parameters:
title
- the title to be displayed in the border of this pane
-
getIcon
public javax.swing.Icon getIcon()
Returns the icon currently displayed in the border of this pane.- Returns:
- the icon currently displayed in the border of this pane
-
setIcon
public void setIcon(javax.swing.Icon icon)
Sets the icon to be displayed in the border of this pane. Some pluggable UIs may impose size constraints for the icon. A size of 16x16 pixels is the recommended icon size.- Parameters:
icon
- the icon to be displayed in the border of this pane
-
isSpecial
public boolean isSpecial()
Returns true if this pane is "special".- Returns:
- true if this pane is "special"
- See Also:
setSpecial(boolean)
-
setSpecial
public void setSpecial(boolean special)
Sets this pane to be "special" or not. Marking aJXTaskPane
asspecial
is only a hint for the pluggable UI which will usually paint it differently (by example by using another color for the border of the pane).Usually the first JXTaskPane in a JXTaskPaneContainer is marked as special because it contains the default set of actions which can be executed given the current context.
- Parameters:
special
- true if this pane is "special", false otherwise
-
setScrollOnExpand
public void setScrollOnExpand(boolean scrollOnExpand)
Should this group be scrolled to be visible on expand.- Parameters:
scrollOnExpand
- true to scroll this group to be visible if this group is expanded.- See Also:
setCollapsed(boolean)
-
isScrollOnExpand
public boolean isScrollOnExpand()
Should this group scroll to be visible after this group was expanded.- Returns:
- true if we should scroll false if nothing should be done.
-
setCollapsed
public void setCollapsed(boolean collapsed)
Expands or collapses this group.As of SwingX 1.6.3, the property change event only fires when the state is accurate. As such, animated task panes fire once the animation is complete.
- Parameters:
collapsed
- true to collapse the group, false to expand it
-
isCollapsed
public boolean isCollapsed()
Returns the collapsed state of this task pane.- Returns:
true
if the task pane is collapsed;false
otherwise
-
setAnimated
public void setAnimated(boolean animated)
Enables or disables animation during expand/collapse transition.- Parameters:
animated
-
-
isAnimated
public boolean isAnimated()
Returns true if this task pane is animated during expand/collapse transition.- Returns:
- true if this task pane is animated during expand/collapse transition.
-
getMnemonic
public int getMnemonic()
Returns the keyboard mnemonic for this component.If the character defined by the mnemonic is found within the task pane's text string, the first occurrence of it will be underlined to indicate the mnemonic to the user.
- Specified by:
getMnemonic
in interfaceMnemonicable
- Returns:
- the keyboard mnemonic
-
setMnemonic
public void setMnemonic(int mnemonic)
Sets the keyboard mnemonic on this component. The mnemonic is the key which when combined with the look and feel's mouseless modifier (usually Alt) will activate this component.A mnemonic must correspond to a single key on the keyboard and should be specified using one of the
VK_XXX
keycodes defined injava.awt.event.KeyEvent
. Mnemonics are case-insensitive, therefore a key event with the corresponding keycode would cause the button to be activated whether or not the Shift modifier was pressed.- Specified by:
setMnemonic
in interfaceMnemonicable
- Parameters:
mnemonic
- the key code which represents the mnemonic- See Also:
KeyEvent
,Mnemonicable.setDisplayedMnemonicIndex(int)
-
updateDisplayedMnemonicIndex
private void updateDisplayedMnemonicIndex(java.lang.String text, int mnemonic)
Update the displayedMnemonicIndex property. This method is called when either text or mnemonic changes. The new value of the displayedMnemonicIndex property is the index of the first occurrence of mnemonic in text.
-
getDisplayedMnemonicIndex
public int getDisplayedMnemonicIndex()
Returns the character, as an index, that the look and feel should provide decoration for as representing the mnemonic character.- Specified by:
getDisplayedMnemonicIndex
in interfaceMnemonicable
- Returns:
- index representing mnemonic character
- See Also:
Mnemonicable.setDisplayedMnemonicIndex(int)
-
setDisplayedMnemonicIndex
public void setDisplayedMnemonicIndex(int index) throws java.lang.IllegalArgumentException
Provides a hint to the look and feel as to which character in the text should be decorated to represent the mnemonic. Not all look and feels may support this. A value of -1 indicates either there is no mnemonic, the mnemonic character is not contained in the string, or the developer does not wish the mnemonic to be displayed.The value of this is updated as the properties relating to the mnemonic change (such as the mnemonic itself, the text...). You should only ever have to call this if you do not wish the default character to be underlined. For example, if the text was 'Save As', with a mnemonic of 'a', and you wanted the 'A' to be decorated, as 'Save As', you would have to invoke
setDisplayedMnemonicIndex(5)
after invokingsetMnemonic(KeyEvent.VK_A)
.- Specified by:
setDisplayedMnemonicIndex
in interfaceMnemonicable
- Parameters:
index
- Index into the String to underline- Throws:
java.lang.IllegalArgumentException
- will be thrown ifindex
is >= length of the text, or < -1- See Also:
Mnemonicable.getDisplayedMnemonicIndex()
-
add
public java.awt.Component add(javax.swing.Action action)
Adds an action to thisJXTaskPane
. Returns a component built from the action. The returned component has been added to theJXTaskPane
.- Parameters:
action
-- Returns:
- a component built from the action
-
getValidatingContainer
public java.awt.Container getValidatingContainer()
- Specified by:
getValidatingContainer
in interfaceJXCollapsiblePane.CollapsiblePaneContainer
- See Also:
JXCollapsiblePane.CollapsiblePaneContainer
-
addImpl
protected void addImpl(java.awt.Component comp, java.lang.Object constraints, int index)
Overridden to redirect call to the content pane.- Overrides:
addImpl
in classjava.awt.Container
-
setLayout
public void setLayout(java.awt.LayoutManager mgr)
Overridden to redirect call to the content pane.- Overrides:
setLayout
in classjava.awt.Container
-
remove
public void remove(java.awt.Component comp)
Overridden to redirect call to the content pane- Overrides:
remove
in classjava.awt.Container
-
remove
public void remove(int index)
Overridden to redirect call to the content pane.- Overrides:
remove
in classjava.awt.Container
-
removeAll
public void removeAll()
Overridden to redirect call to the content pane.- Overrides:
removeAll
in classjava.awt.Container
-
paramString
protected java.lang.String paramString()
- Overrides:
paramString
in classjavax.swing.JPanel
- See Also:
JComponent.paramString()
-
-