Package com.jidesoft.dialog
Class MultiplePageDialogPane
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.jidesoft.dialog.StandardDialogPane
com.jidesoft.dialog.MultiplePageDialogPane
- All Implemented Interfaces:
ButtonNames
,ImageObserver
,MenuContainer
,Serializable
,Accessible
MultiplePageDialogPane is a StandardDialogPane which can have multiple AbstractDialogPages. You can choose one from
four predefined styles of how to change the page visibility. Those four styles are TAB_STYLE, ICON_STYLE, LIST_STYLE
and TREE_STYLE.
To use this class, just create a PageList of AbstractDialogPage and call setPageList() to set to this dialog. Based
on the style, the class will automatically layout those pages correctly and hook up actions to switch based on user
selection.
As AbstractDialogPage extends AbstractPage, so you can always use PageListener to decide what to do when page is
opened, closing, closed, activated or deactivated.
We automatically create a button panel which have three button - OK, Cancel and Apply. The ButtonPanel listens to
ButtonEvent from all the pages. You can simply fireButtonEvent in the page to change the state of those buttons. Or
if you want to create your own button panel, just override createButtonPanel() method.
If you choose LIST_STYLE and TREE_STYLE, you can set your own ListCellRenderer and TreeCellRenderer. Just call
setListCellRenderer() and setTreeCellRenderer(). The value passed in the renderer is an instance of
AbstractDialogPage associated with that list row or tree node.
MultiplePageDialogPane
has lazy loading feature. So when you are done setup the page list, you need to
call StandardDialogPane.initComponents()
to initialize everything. This method will be called automatically if the dialog pane
is added to StandardDialog.- See Also:
-
Nested Class Summary
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
FieldsModifier and TypeFieldDescriptionstatic final int
Predefined style of multiple page dialog.static final int
Predefined style of multiple page dialog.static final int
Predefined style of multiple page dialog.static final int
Predefined style of multiple page dialog.Fields inherited from class com.jidesoft.dialog.StandardDialogPane
_bannerPanel, _buttonPanel, _contentPanel, PROPERTY_CANCEL_ACTION, PROPERTY_DEFAULT_ACTION
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
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface com.jidesoft.dialog.ButtonNames
APPLY, BACK, BROWSE, CANCEL, CLEAR, CLOSE, DETAILS, EDIT, EXIT, FIND, FIND_NEXT, FINISH, FORWARD, HELP, NEW, NEXT, NO, OK, OPEN, PRINT, REPLACE, RESET, RETRY, RUN, SAVE, SAVE_AS, STOP, YES
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a non-modal MultiplePageDialog without a title and without a specifiedFrame
owner.MultiplePageDialogPane
(int style) Creates a modal or non-modal MultiplePageDialog with the specified style, the specified title and the specified ownerFrame
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
configureTree
(JTree tree) Configure the JTree used in TREE_STYLE dialog.Implements the method in StandardDialog.Creates the button panel.Implements the method in StandardDialog.protected JideButton
createIconButton
(String title, Icon icon) Creates the button for each icon.protected ButtonPanel
Creates the ButtonPanel used by IconPanel.protected JComponent
Creates the panel that contains several icons.Creates the index panel based on the style.protected JList
createList
(DefaultListModel listModel) Creates list that is used in LIST_STYLE dialog's index panel.protected ListCellRenderer
Creates a list cell renderer used by list in LIST_STYLE dialog's index panel.protected JComponent
Creates the pages panel.protected JTabbedPane
Creates the JTabbedPane used by TAB_STYLE dialog.protected JTree
Creates tree that is used in TREE_STYLE dialog's index panel.protected TreeCellRenderer
Creates the tree cell renderer used by tree in TREE_STYLE dialog's index panel.protected MutableTreeNode
createTreeNode
(AbstractDialogPage dialogPage) Create tree node for TREE_STYLE pages.Gets the apply button.Gets the cancel action.Gets the cancel button.Gets the current selected page.Gets the index panel.Gets the initial page title.protected ListCellRenderer
Gets the cell renderer used by the list.Gets the OK action.Gets the OK Button only if you didn't override the createButtonPanel() and remove the OK button.Gets the page list of this dialog.Gets the pages panel.int
getStyle()
Gets the style of this dialog.protected TreeCellRenderer
Gets the cell renderer used by the tree.void
setCancelAction
(AbstractAction cancelAction) Changes the default cancel action.protected void
setCurrentPage
(AbstractDialogPage currentPage) protected void
setCurrentPage
(AbstractDialogPage currentPage, Object source) protected void
setCurrentPage
(String pageTitle) void
setInitialPageTitle
(String initialPageTitle) Sets the initial page title.void
setListCellRenderer
(ListCellRenderer listCellRenderer) Sets the list cell renderer that will be used by JList when the style is LIST_STYLE.void
setOKAction
(AbstractAction okAction) Changes the default OK action.void
setPageList
(PageList pageList) Sets the page list of this dialog.void
setStyle
(int style) Sets the style of this dialog.void
setTreeCellRenderer
(TreeCellRenderer treeCellRenderer) Sets the tree cell renderer that will be used by JTree when the style is TREE_STYLE.protected JComponent
setupContentPanel
(JComponent indexPanel, JComponent pagesPanel) Setups the content panel.protected void
showCurrentPage
(AbstractDialogPage currentPage) Displays the current page.Methods inherited from class com.jidesoft.dialog.StandardDialogPane
getBannerPanel, getButtonPanel, getContentPanel, getDefaultAction, getDefaultCancelAction, getInitFocusedComponent, initComponents, layoutComponents, setDefaultAction, setDefaultCancelAction, setInitFocusedComponent
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, 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, 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, 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 Details
-
TAB_STYLE
public static final int TAB_STYLEPredefined style of multiple page dialog.- See Also:
-
TREE_STYLE
public static final int TREE_STYLEPredefined style of multiple page dialog.- See Also:
-
LIST_STYLE
public static final int LIST_STYLEPredefined style of multiple page dialog.- See Also:
-
ICON_STYLE
public static final int ICON_STYLEPredefined style of multiple page dialog.- See Also:
-
_tree
-
-
Constructor Details
-
MultiplePageDialogPane
Creates a non-modal MultiplePageDialog without a title and without a specifiedFrame
owner. A shared, hidden frame will be set as the owner of the dialog. By default TAB_STYLE is used.- Throws:
HeadlessException
-
MultiplePageDialogPane
public MultiplePageDialogPane(int style) Creates a modal or non-modal MultiplePageDialog with the specified style, the specified title and the specified ownerFrame
. Ifowner
isnull
, a shared, hidden frame will be set as the owner of this dialog. All constructors defer to this one.- Parameters:
style
- the style. It must be one of the following: TAB_STYLE, ICON_STYLE, LIST_STYLE or TREE_STYLE.- Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true.- See Also:
-
-
Method Details
-
createBannerPanel
Implements the method in StandardDialog. You can override this method to create a BannerPanel.- Specified by:
createBannerPanel
in classStandardDialogPane
- Returns:
- the BannerPanel
-
createContentPanel
Implements the method in StandardDialog. You can override this method to create a ContentPanel. By default, a JPanel with BorderLayout is created. IndexPanel is added to WEST and PagesPanel is added to CENTER.- Specified by:
createContentPanel
in classStandardDialogPane
- Returns:
- the ContentPanel
-
setupContentPanel
Setups the content panel. It will use the index panel and the pages panel created earlier and put it into another panel.- Parameters:
indexPanel
- the index panel. It has the navigation control to control which page to show.pagesPanel
- the pages panel. It contains all the pages of this dialog.- Returns:
- the panel that contains both index panel and pages panel.
-
createButtonPanel
Creates the button panel. It has three buttons - OK, Cancel and Apply. If you want to create your own button panel, just override this method.- Specified by:
createButtonPanel
in classStandardDialogPane
- Returns:
- button panel
- See Also:
-
getOkButton
Gets the OK Button only if you didn't override the createButtonPanel() and remove the OK button.- Returns:
- the OK Button
-
getCancelButton
Gets the cancel button. only if you didn't override the createButtonPanel() and remove the cancel button.- Returns:
- the cancel button.
-
getApplyButton
Gets the apply button. only if you didn't override the createButtonPanel() and remove the apply button.- Returns:
- the apply button.
-
setCancelAction
Changes the default cancel action.- Parameters:
cancelAction
-
-
getCancelAction
Gets the cancel action.- Returns:
- the cancel action.
-
setOKAction
Changes the default OK action.- Parameters:
okAction
-
-
getOKAction
Gets the OK action.- Returns:
- the OK action.
-
createPagesPanel
Creates the pages panel. If it's TAB_STYLE, a tabbed pane will be created. If it's any other styles, a JPanel with CardLayout will be created.- Returns:
- a panel containing all the pages.
-
createTabbedPane
Creates the JTabbedPane used by TAB_STYLE dialog.- Returns:
- a JTabbedPane
-
createIndexPanel
Creates the index panel based on the style.- Returns:
- the index panel.
-
setPageList
Sets the page list of this dialog. User must call this method before the dialog is set visible.- Parameters:
pageList
-
-
getPageList
Gets the page list of this dialog. -
getCurrentPage
Gets the current selected page.- Returns:
- the current selected page.
-
setCurrentPage
-
setCurrentPage
-
setCurrentPage
-
showCurrentPage
Displays the current page. If it is TAB_STYLE, this method will simply select the tab that has the current page. If it is any of the other styles, this method will show the page that is already added in a CardLayout in createPagePanel method.- Parameters:
currentPage
-
-
createTreeNode
Create tree node for TREE_STYLE pages.- Parameters:
dialogPage
- the corresponding dialog page.- Returns:
- the tree node.
-
createTree
Creates tree that is used in TREE_STYLE dialog's index panel. Below is the code we used. If you just want to have a different cell renderer, you can just callsetTreeCellRenderer(javax.swing.tree.TreeCellRenderer)
to set a new one.UIManager.put("Tree.hash", Color.white); return new JTree(root);
- Parameters:
root
-- Returns:
- tree
-
configureTree
Configure the JTree used in TREE_STYLE dialog. Subclass can override this method to configure the JTree to the way you want. Below is the default implementation of this method.tree.setToggleClickCount(1); tree.setCellRenderer(createTreeCellRenderer()); tree.setRootVisible(false); tree.setShowsRootHandles(false); tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { if (tree.getSelectionPath() == null) { return; } DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent(); // comment this while block if you want the parent page shows its own page instead of showing its first child page. while (!treeNode.isLeaf()) { final DefaultMutableTreeNode tn = treeNode; Runnable runnable = new Runnable() { public void run() { tree.expandPath(new TreePath(tn.getPath())); } }; SwingUtilities.invokeLater(runnable); treeNode = (DefaultMutableTreeNode) treeNode.getChildAt(0); } if (treeNode != null) { Object userObject = treeNode.getUserObject(); if (userObject instanceof AbstractDialogPage) { setCurrentPage((AbstractDialogPage) userObject, tree); } } } });
- Parameters:
tree
-
-
createList
Creates list that is used in LIST_STYLE dialog's index panel. Below is the code we used. If you just want to have a different cell renderer, you can just callsetListCellRenderer(javax.swing.ListCellRenderer)
to set a new one.JList list = new JList(listModel); list.setCellRenderer(createListCellRenderer()); return list;
- Parameters:
listModel
-- Returns:
- list.
-
createIconPanel
Creates the panel that contains several icons. Each icon represents for a page. This is only used for ICON_STYLE.- Returns:
- a panel that contains several icons.
-
createIconButtonPanel
Creates the ButtonPanel used by IconPanel. By default, we create it usingnew ScrollableButtonPanel(SwingConstants.TOP, ButtonPanel.SAME_SIZE)
.- Returns:
- the ButtonPanel.
-
createIconButton
Creates the button for each icon.- Parameters:
title
-icon
-- Returns:
- the button
-
getStyle
public int getStyle()Gets the style of this dialog.- Returns:
- the style. It can be TAB_STYLE, ICON_STYLE, LIST_STYLE or TREE_STYLE.
-
setStyle
public void setStyle(int style) Sets the style of this dialog. This class doesn't support change style on fly. You can only change style before the dialog is set to visible.- Parameters:
style
- It must be one of the following: TAB_STYLE, ICON_STYLE, LIST_STYLE or TREE_STYLE.
-
getIndexPanel
Gets the index panel.- Returns:
- the index panel.
-
getPagesPanel
Gets the pages panel.- Returns:
- the pages panel.
-
getTreeCellRenderer
Gets the cell renderer used by the tree. It's used only when the style is TREE_STYLE.- Returns:
- the tree cell renderer.
-
setTreeCellRenderer
Sets the tree cell renderer that will be used by JTree when the style is TREE_STYLE.- Parameters:
treeCellRenderer
-
-
getListCellRenderer
Gets the cell renderer used by the list. It's used only when the style is LIST_STYLE.- Returns:
- the list cell renderer.
-
setListCellRenderer
Sets the list cell renderer that will be used by JList when the style is LIST_STYLE.- Parameters:
listCellRenderer
-
-
createListCellRenderer
Creates a list cell renderer used by list in LIST_STYLE dialog's index panel.- Returns:
- the list cell renderer.
-
createTreeCellRenderer
Creates the tree cell renderer used by tree in TREE_STYLE dialog's index panel.- Returns:
- the tree cell renderer.
-
getInitialPageTitle
Gets the initial page title. Initial page is the page that will be selected when the dialog is just opened. Please note the title is the full title. In most case it's just the title of the page. Only in TREE_STYLE, it should be a list of titles that concatenate with '.'.- Returns:
- the initial page title.
-
setInitialPageTitle
Sets the initial page title. Initial page is the page that will be selected when the dialog.- Parameters:
initialPageTitle
-
-