Package com.jidesoft.dialog
Class StandardDialog
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
javax.swing.JDialog
com.jidesoft.dialog.StandardDialog
- All Implemented Interfaces:
ButtonNames,ImageObserver,MenuContainer,Serializable,Accessible,RootPaneContainer,WindowConstants
- Direct Known Subclasses:
MultiplePageDialog
StandardDialog is a dialog template. However several things are added to it to make it easier to use.
- Laziness. The content will not be filled until pack() or show() are called.
- Default action and cancel action. User can set the default action and cancel action of this dialog. By default, the ENTER key will trigger the default action and the ESC key will trigger the cancel action and set the dialog result to RESULT_CANCELLED.
- Divide the whole ContentPane of the dialog into three parts - content panel, button panel and banner panel. By default, they are added to the CENTER, SOUTH and NORTH of a BorderLayout respectively. There isn't anything special about this. However if all your dialogs use this pattern, it will automatically make the user interface more consistent.
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialogNested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityTypeNested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.TypeNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptioncom.jidesoft.dialog.StandardDialog.StandardDialogPropertyChangeListenerprotected StandardDialogPanestatic final intDialog result.static final intDialog result.Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabledFields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPEFields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields 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, YESFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE -
Constructor Summary
ConstructorsConstructorDescriptionStandardDialog(Dialog owner) StandardDialog(Dialog owner, boolean modal) StandardDialog(Dialog owner, String title) StandardDialog(Dialog owner, String title, boolean modal) StandardDialog(Dialog owner, String title, boolean modal, GraphicsConfiguration gc) StandardDialog(Frame owner) StandardDialog(Frame owner, boolean modal) StandardDialog(Frame owner, String title) StandardDialog(Frame owner, String title, boolean modal) StandardDialog(Frame owner, String title, boolean modal, GraphicsConfiguration gc) StandardDialog(Window owner) StandardDialog(Window owner, Dialog.ModalityType modalityType) StandardDialog(Window owner, String title) StandardDialog(Window owner, String title, Dialog.ModalityType modalityType) StandardDialog(Window owner, String title, Dialog.ModalityType modalityType, GraphicsConfiguration gc) -
Method Summary
Modifier and TypeMethodDescriptionabstract JComponentSubclasses should implement this method to create the banner panel.abstract ButtonPanelSubclasses should implement this method to create the button panel.abstract JComponentSubclasses should implement this method to create the content panel.Creates a standard OK/Cancel button panel.protected StandardDialogPaneGets the banner panel created by createBannerPanel.Gets the banner panel created by createButtonPanel.Gets the banner panel created by createContentPanel.Gets the default action.Get default cancel action.intGets the result.Gets the initial focused component when dialog is shown.protected voidCall three createXxxPanel methods and layout them using BorderLayout.final voidForce the initComponent() method implemented in the child class to be called.voidpack()voidsetDefaultAction(Action defaultAction) Sets the default action.voidsetDefaultCancelAction(Action defaultCancelAction) Set default cancel action.voidsetDialogResult(int dialogResult) Sets the dialog result.voidsetInitFocusedComponent(Component initFocusedComponent) Sets the initial focused component when dialog is shown.voidshow()Deprecated.Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, updateMethods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, setVisible, toBackMethods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, toFrontMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
_standardDialogPane
-
RESULT_CANCELLED
public static final int RESULT_CANCELLEDDialog result.- See Also:
-
RESULT_AFFIRMED
public static final int RESULT_AFFIRMEDDialog result.- See Also:
-
_propertyChangeListener
public com.jidesoft.dialog.StandardDialog.StandardDialogPropertyChangeListener _propertyChangeListener
-
-
Constructor Details
-
StandardDialog
public StandardDialog() -
StandardDialog
-
StandardDialog
-
StandardDialog
-
StandardDialog
-
StandardDialog
-
StandardDialog
-
StandardDialog
-
StandardDialog
-
StandardDialog
-
StandardDialog
-
StandardDialog
-
StandardDialog
-
StandardDialog
-
StandardDialog
-
StandardDialog
public StandardDialog(Window owner, String title, Dialog.ModalityType modalityType, GraphicsConfiguration gc)
-
-
Method Details
-
getDialogResult
public int getDialogResult()Gets the result.- Returns:
- the result.
-
setDialogResult
public void setDialogResult(int dialogResult) Sets the dialog result.- Parameters:
dialogResult- the new dialog result.
-
getDefaultCancelAction
Get default cancel action. Default cancel action will be triggered when ESC is pressed.- Returns:
- the default cancel action
-
setDefaultCancelAction
Set default cancel action. Default cancel action will be triggered when ESC is pressed.- Parameters:
defaultCancelAction- the default cancel action
-
getDefaultAction
Gets the default action. Default action will be trigger when ENTER key is pressed.- Returns:
- the default action.
-
setDefaultAction
Sets the default action. Default action will be trigger when ENTER key is pressed.- Parameters:
defaultAction- the default action.
-
pack
public void pack() -
show
Deprecated.As of JDK version 1.5, replaced byComponent.setVisible(boolean). -
initialize
public final void initialize()Force the initComponent() method implemented in the child class to be called. If this method is called more than once on a given object, all calls but the first do nothing. -
initComponents
protected void initComponents()Call three createXxxPanel methods and layout them using BorderLayout. By default, banner panel, content panel and button panel are added to NORTH, CENTER and SOUTH of BorderLayout respectively. You can override this method if you want to layout them in another way. -
getInitFocusedComponent
Gets the initial focused component when dialog is shown.- Returns:
- the initial focused component
-
setInitFocusedComponent
Sets the initial focused component when dialog is shown.- Parameters:
initFocusedComponent- the initial focused component.
-
getBannerPanel
Gets the banner panel created by createBannerPanel.- Returns:
- the banner panel.
-
getContentPanel
Gets the banner panel created by createContentPanel.- Returns:
- the content panel.
-
getButtonPanel
Gets the banner panel created by createButtonPanel.- Returns:
- the button panel.
-
getStandardDialogPane
-
createBannerPanel
Subclasses should implement this method to create the banner panel. By default banner panel will appear on top of the dialog unless you override initComponent() method. Banner panel is really used to balance the layout of dialog to make the dialog looking good. However it can be used to show some help text. It is highly recommended to use ourBannerPanelIf subclass doesn't want to have a banner panel, just return null.- Returns:
- the banner panel.
-
createContentPanel
Subclasses should implement this method to create the content panel. This is the main panel of the dialog which will be added to the center of the dialog. Subclass should never return null.- Returns:
- the content panel.
-
createButtonPanel
Subclasses should implement this method to create the button panel. 90% of dialogs have buttons. It is highly recommended to use ourButtonPanel.- Returns:
- the button panel.
- See Also:
-
createOKCancelButtonPanel
Creates a standard OK/Cancel button panel.- Returns:
- a button panel that has OK/Cancel button.
-
createStandardDialogPane
-
Component.setVisible(boolean).