|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
javax.swing.JDialog
org.openbp.swing.components.JMsgBox
public class JMsgBox
General purpose modal message box component.
To be used similar to the JOptionPane class.
This class subclasses the JDialog class in order to provide functionality
commonly needed in message boxes.
The message box provides some additional features in addition to the features
known by JOptionPane:
- Resource based images and button texts
- 'Yes for all'/'No for all' button
- Extended accelerators
- Help support using help strategy (planned)
- Stack trace display support using an JTextField (planned)
A special feature is the TYPE_OKLATER flag for the message type.
If set, the message box will be displayed at a later time using
SwingUtilities.invokeLater(Runnable) method.
This is very useful if e. g. a field validation is performed from withing a
focus lost handler. Displaying the message box at this point in time would lead
to a hangup of the Swing event thread. Using TYPE_OKLATER will immediately return,
displaying the dialog after the processing of the current event has taken place.
| Nested Class Summary | |
|---|---|
static interface |
JMsgBox.DefaultOwnerProvider
|
| Nested classes/interfaces inherited from class javax.swing.JDialog |
|---|
javax.swing.JDialog.AccessibleJDialog |
| Nested classes/interfaces inherited from class java.awt.Dialog |
|---|
java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType |
| Nested classes/interfaces inherited from class java.awt.Window |
|---|
java.awt.Window.AccessibleAWTWindow |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
java.awt.Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
static int |
DEFAULT_ABORT
Message type: Default button abort |
static int |
DEFAULT_CANCEL
Message type: Default button cancel |
static int |
DEFAULT_IGNORE
Message type: Default button ignore |
static int |
DEFAULT_NO
Message type: Default button no |
static int |
DEFAULT_OK
Message type: Default button ok |
static int |
DEFAULT_RETRY
Message type: Default button retry |
static int |
DEFAULT_YES
Message type: Default button yes |
static JMsgBox.DefaultOwnerProvider |
defaultOwnerProvider
Default message box owner provider |
static int |
ICON_ERROR
Message type: Error icon |
static int |
ICON_FATAL
Message type: Fatal icon |
static int |
ICON_INFO
Message type: Info icon |
static int |
ICON_QUESTION
Message type: Question icon |
static int |
ICON_WARNING
Message type: Warning icon |
static int |
TYPE_ABORT
Message type: Abort button |
static int |
TYPE_CANCEL
Message type: Cancel button |
static int |
TYPE_DO_NOT_SHOW_AGAIN
Additional message type: Display 'Do not show this message again' checkbox |
static int |
TYPE_FOR_ALL
Message type: Yes/No for all button |
static int |
TYPE_IGNORE
Message type: Ignore button |
static int |
TYPE_NO
Message type: No button |
static int |
TYPE_NO_FOR_ALL
Message type: No for all button |
static int |
TYPE_OK
Message type: Ok button |
static int |
TYPE_OKCANCEL
Message type: Ok and cancel button |
static int |
TYPE_OKLATER
Message type: Ok button |
static int |
TYPE_RETRY
Message type: Retry button |
static int |
TYPE_YES
Message type: Yes button |
static int |
TYPE_YES_FOR_ALL
Message type: Yes for all button |
static int |
TYPE_YESNO
Message type: Yes and no button |
static int |
TYPE_YESNOCANCEL
Message type: Yes, no and cancel button |
| Fields inherited from class javax.swing.JDialog |
|---|
accessibleContext, rootPane, rootPaneCheckingEnabled |
| Fields inherited from class java.awt.Dialog |
|---|
DEFAULT_MODALITY_TYPE |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface javax.swing.WindowConstants |
|---|
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
JMsgBox(java.awt.Component owner,
java.lang.String title,
java.lang.String msg,
int msgType)
Constructor. |
|
| Method Summary | |
|---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
ActionListener implementation - determines the return value of the message box. |
static javax.swing.JFrame |
getParentFrame(java.awt.Component c)
Determines the parent frame of a component. |
ResourceCollection |
getResource()
Gets the actual resource to use for this message box. |
java.lang.String |
getResourcePrefix()
Gets the actual resource to use for this message box. |
int |
getUserChoice()
Gets the the return value of the message box. |
void |
initDialog()
Initializes the dialog. |
static void |
setDefaultOwnerProvider(JMsgBox.DefaultOwnerProvider defaultOwnerProviderArg)
Sets the default message box owner provider. |
static void |
setDefaultResourceCollection(ResourceCollection defaultResourceCollectionArg)
Sets the message box default resource. |
static void |
setDefaultTitle(java.lang.String defaultTitleArg)
Sets the default title. |
void |
setResource(ResourceCollection resourceCollection)
Sets the actual resource to use for this message box. |
void |
setResourcePrefix(java.lang.String resourcePrefix)
Sets the actual resource to use for this message box. |
static int |
show(java.awt.Component owner,
java.lang.String msg,
int msgType)
Shows a modal message box using the default title. |
static int |
show(java.awt.Component owner,
java.lang.String msg,
java.lang.Object[] msgArgs,
int msgType)
Shows a modal message box using the default title. |
static int |
show(java.awt.Component owner,
java.lang.String title,
java.lang.String msg,
int msgType)
Shows a modal message box. |
static int |
show(java.awt.Component owner,
java.lang.String title,
java.lang.String msg,
java.lang.Object[] msgArgs,
int msgType)
Shows a modal message box. |
static int |
showFormat(java.awt.Component owner,
java.lang.String msg,
java.lang.Object msgArg1,
int msgType)
Shows a modal message box using the default title. |
static int |
showFormat(java.awt.Component owner,
java.lang.String msg,
java.lang.Object msgArg1,
java.lang.Object msgArg2,
int msgType)
Shows a modal message box using the default title. |
static int |
showFormat(java.awt.Component owner,
java.lang.String msg,
java.lang.Object msgArg1,
java.lang.Object msgArg2,
java.lang.Object msgArg3,
int msgType)
Shows a modal message box using the default title. |
| 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, update |
| Methods inherited from class java.awt.Dialog |
|---|
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setResizable, setTitle, setUndecorated, setVisible, show, toBack |
| Methods inherited from class java.awt.Window |
|---|
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, toFront |
| Methods 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, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, 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, isOpaque, 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, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int TYPE_OK
public static final int TYPE_CANCEL
public static final int TYPE_OKCANCEL
public static final int TYPE_YES
public static final int TYPE_NO
public static final int TYPE_YESNO
public static final int TYPE_YESNOCANCEL
public static final int TYPE_YES_FOR_ALL
public static final int TYPE_NO_FOR_ALL
public static final int TYPE_FOR_ALL
public static final int TYPE_ABORT
public static final int TYPE_RETRY
public static final int TYPE_IGNORE
public static final int TYPE_DO_NOT_SHOW_AGAIN
public static final int ICON_INFO
public static final int ICON_WARNING
public static final int ICON_ERROR
public static final int ICON_FATAL
public static final int ICON_QUESTION
public static final int DEFAULT_OK
public static final int DEFAULT_CANCEL
public static final int DEFAULT_YES
public static final int DEFAULT_NO
public static final int DEFAULT_ABORT
public static final int DEFAULT_RETRY
public static final int DEFAULT_IGNORE
public static final int TYPE_OKLATER
public static JMsgBox.DefaultOwnerProvider defaultOwnerProvider
| Constructor Detail |
|---|
public JMsgBox(java.awt.Component owner,
java.lang.String title,
java.lang.String msg,
int msgType)
owner - Parent window that opened the message boxtitle - Title of the message boxmsg - Message to display in the message boxmsgType - Msg type (see the constants of this class)| Method Detail |
|---|
public int getUserChoice()
public ResourceCollection getResource()
public void setResource(ResourceCollection resourceCollection)
public java.lang.String getResourcePrefix()
public void setResourcePrefix(java.lang.String resourcePrefix)
public void initDialog()
public static int show(java.awt.Component owner,
java.lang.String msg,
int msgType)
owner - Owner window of this message boxmsg - Message to displaymsgType - Msg type (see the constants of this class)
public static int show(java.awt.Component owner,
java.lang.String title,
java.lang.String msg,
int msgType)
owner - Owner window of this message boxtitle - Message box titlemsg - Message to displaymsgType - Msg type (see the constants of this class)
public static int show(java.awt.Component owner,
java.lang.String msg,
java.lang.Object[] msgArgs,
int msgType)
owner - Owner window of this message boxmsg - Message to displaymsgArgs - Message arguments (for details see the MsgFormat class)msgType - Msg type (see the constants of this class)
public static int show(java.awt.Component owner,
java.lang.String title,
java.lang.String msg,
java.lang.Object[] msgArgs,
int msgType)
owner - Owner window of this message boxtitle - Message box titlemsg - Message to displaymsgArgs - Message arguments (for details see the MsgFormat class)msgType - Msg type (see the constants of this class)
public static int showFormat(java.awt.Component owner,
java.lang.String msg,
java.lang.Object msgArg1,
int msgType)
owner - Owner window of this message boxmsg - Message to displaymsgArg1 - First message argument (for details see the MsgFormat class)msgType - Msg type (see the constants of this class)
public static int showFormat(java.awt.Component owner,
java.lang.String msg,
java.lang.Object msgArg1,
java.lang.Object msgArg2,
int msgType)
owner - Owner window of this message boxmsg - Message to displaymsgArg1 - First message argument (for details see the MsgFormat class)msgArg2 - First message argument (for details see the MsgFormat class)msgType - Msg type (see the constants of this class)
public static int showFormat(java.awt.Component owner,
java.lang.String msg,
java.lang.Object msgArg1,
java.lang.Object msgArg2,
java.lang.Object msgArg3,
int msgType)
owner - Owner window of this message boxmsg - Message to displaymsgArg1 - First message argument (for details see the MsgFormat class)msgArg2 - First message argument (for details see the MsgFormat class)msgArg3 - First message argument (for details see the MsgFormat class)msgType - Msg type (see the constants of this class)
public static void setDefaultResourceCollection(ResourceCollection defaultResourceCollectionArg)
public static void setDefaultTitle(java.lang.String defaultTitleArg)
public static void setDefaultOwnerProvider(JMsgBox.DefaultOwnerProvider defaultOwnerProviderArg)
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed in interface java.awt.event.ActionListenerpublic static javax.swing.JFrame getParentFrame(java.awt.Component c)
c - Component
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||