Class JXTaskPane

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, JXCollapsiblePane.CollapsiblePaneContainer, Mnemonicable

@JavaBean public class JXTaskPane extends JPanel implements JXCollapsiblePane.CollapsiblePaneContainer, Mnemonicable
JXTaskPane is a container for tasks and other arbitrary components.

Several JXTaskPanes are usually grouped together within a JXTaskPaneContainer. However it is not mandatory to use a JXTaskPaneContainer as the parent for JXTaskPane. The JXTaskPane can be added to any other container. See JXTaskPaneContainer 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 an icon, a title and can be marked as special. Marking a JXTaskPane as special (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 created JXTaskPane, 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);
 
 
Author:
Frederic Lavigne, Karl George Schaefer
See Also:
  • Field Details

    • uiClassID

      public static final String uiClassID
      JXTaskPane pluggable UI key swingx/TaskPaneUI
      See Also:
    • SCROLL_ON_EXPAND_CHANGED_KEY

      public static final String SCROLL_ON_EXPAND_CHANGED_KEY
      Used when generating PropertyChangeEvents for the "scrollOnExpand" property
      See Also:
    • TITLE_CHANGED_KEY

      public static final String TITLE_CHANGED_KEY
      Used when generating PropertyChangeEvents for the "title" property
      See Also:
    • ICON_CHANGED_KEY

      public static final String ICON_CHANGED_KEY
      Used when generating PropertyChangeEvents for the "icon" property
      See Also:
    • SPECIAL_CHANGED_KEY

      public static final String SPECIAL_CHANGED_KEY
      Used when generating PropertyChangeEvents for the "special" property
      See Also:
    • ANIMATED_CHANGED_KEY

      public static final String ANIMATED_CHANGED_KEY
      Used when generating PropertyChangeEvents for the "animated" property
      See Also:
  • Constructor Details

    • JXTaskPane

      public JXTaskPane()
      Creates a new empty JXTaskPane.
    • JXTaskPane

      public JXTaskPane(String title)
      Creates a new task pane with the specified title.
      Parameters:
      title - the title to use
    • JXTaskPane

      public JXTaskPane(Icon icon)
      Creates a new task pane with the specified icon.
      Parameters:
      icon - the icon to use
    • JXTaskPane

      public JXTaskPane(String title, Icon icon)
      Creates a new task pane with the specified title and icon.
      Parameters:
      title - the title to use
      icon - the icon to use
  • Method Details

    • getContentPane

      public Container getContentPane()
      Returns the contentPane object for this JXTaskPane.
      Returns:
      the contentPane property
    • updateUI

      public void updateUI()
      Notification from the UIManager that the LaF has changed. Replaces the current UI object with the latest version from the UIManager.
      Overrides:
      updateUI in class JPanel
      See Also:
    • setUI

      public void setUI(TaskPaneUI ui)
      Sets the LaF object that renders this component.
      Parameters:
      ui - the TaskPaneUI LaF object
      See Also:
    • getUIClassID

      public String getUIClassID()
      Returns the name of the LaF class that renders this component.
      Overrides:
      getUIClassID in class JPanel
      Returns:
      the string uiClassID
      See Also:
    • getTitle

      public 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(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 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(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

      public void setSpecial(boolean special)
      Sets this pane to be "special" or not. Marking a JXTaskPane as special 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:
    • 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 - enables the animation
    • 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 interface Mnemonicable
      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 in java.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 interface Mnemonicable
      Parameters:
      mnemonic - the key code which represents the mnemonic
      See Also:
    • 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 interface Mnemonicable
      Returns:
      index representing mnemonic character
      See Also:
    • setDisplayedMnemonicIndex

      public void setDisplayedMnemonicIndex(int index) throws 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 invoking setMnemonic(KeyEvent.VK_A).

      Specified by:
      setDisplayedMnemonicIndex in interface Mnemonicable
      Parameters:
      index - Index into the String to underline
      Throws:
      IllegalArgumentException - will be thrown if index is >= length of the text, or < -1
      See Also:
    • add

      public Component add(Action action)
      Adds an action to this JXTaskPane. Returns a component built from the action. The returned component has been added to the JXTaskPane.
      Parameters:
      action - ui action
      Returns:
      a component built from the action
    • getValidatingContainer

      public Container getValidatingContainer()
      Description copied from interface: JXCollapsiblePane.CollapsiblePaneContainer
      TODO maven-javadoc-plugin 3.3.2 needs a doc here
      Specified by:
      getValidatingContainer in interface JXCollapsiblePane.CollapsiblePaneContainer
      Returns:
      Container
      See Also:
    • addImpl

      protected void addImpl(Component comp, Object constraints, int index)
      Overridden to redirect call to the content pane.
      Overrides:
      addImpl in class Container
    • setLayout

      public void setLayout(LayoutManager mgr)
      Overridden to redirect call to the content pane.
      Overrides:
      setLayout in class Container
    • remove

      public void remove(Component comp)
      Overridden to redirect call to the content pane
      Overrides:
      remove in class Container
    • remove

      public void remove(int index)
      Overridden to redirect call to the content pane.
      Overrides:
      remove in class Container
    • removeAll

      public void removeAll()
      Overridden to redirect call to the content pane.
      Overrides:
      removeAll in class Container
    • paramString

      protected String paramString()
      Overrides:
      paramString in class JPanel
      See Also: