L'Oeuf

Email me

Site in English
Site en Français


Class MessageBox

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Dialog
                          |
                          +--MessageBox

public class MessageBox
extends java.awt.Dialog
implements java.awt.event.ActionListener

This class is a dialog box that displays a title, a message and some buttons such as Yes, No, Cancel, OK, Abort, Retry, or Ignore.

Please report any bug/enhancement proposal to the author.

** See http://www.chez.com/elefevre for updates and more stuff to download. **

Version:
v1.0.1, 15 Nov 1998:
  • all variables not of class Button are made private
  • cosmetic enhancements in the documentation
v1.0, 26 Oct 1997.
Author:
Eric Lefevre (e-mail: eric.lefevre@usa.net)
See Also:
Serialized Form

Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
Field Summary
static java.awt.Button ABORT
          A Cancel Button to give in parameter.
private  java.awt.Button button1
          Buttons for the dialog box.
private  java.awt.Button button2
           
private  java.awt.Button button3
           
private  java.awt.Button button4
           
private  java.awt.Button button5
           
private  java.awt.Button button6
           
private  java.awt.Button button7
           
private  java.awt.Button buttonReturn
          The Button that will be returned.
static java.awt.Button CANCEL
          A Cancel Button to give in parameter.
private  java.awt.Panel controlPanel
          The zone that contains the buttons.
static java.awt.Button IGNORE
          A Ignore Button to give in parameter.
private  java.awt.Label messageLabel
          The message in the box.
static java.awt.Button NO
          A No Button to give in parameter.
private static java.awt.Button nobuttonButton
          An empty button.
static java.awt.Button OK
          A OK Button to give in parameter.
static java.awt.Button RETRY
          A Retry Button to give in parameter.
static java.awt.Button YES
          A Yes Button to give in parameter.
 
Fields inherited from class java.awt.Dialog
base, keepBlocking, modal, nameCounter, resizable, serialVersionUID, title
 
Fields inherited from class java.awt.Window
active, base, focusMgr, inputContext, nameCounter, OPENED, ownedWindowList, serialVersionUID, state, warningString, weakThis, windowListener, windowSerializedDataVersion
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dispatcher, layoutMgr, maxSize, ncomponents, serialVersionUID
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, assert, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, serialVersionUID, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Constructor Summary
MessageBox(java.awt.Frame parent, java.lang.String title, java.lang.String message, java.awt.Button b1)
          Constructs a dialog box with one chosen button.
MessageBox(java.awt.Frame parent, java.lang.String title, java.lang.String message, java.awt.Button b1, java.awt.Button b2)
          Constructs a dialog box with two chosen buttons.
MessageBox(java.awt.Frame parent, java.lang.String title, java.lang.String message, java.awt.Button b1, java.awt.Button b2, java.awt.Button b3)
          Constructs a dialog box with three chosen buttons.
MessageBox(java.awt.Frame parent, java.lang.String title, java.lang.String message, java.awt.Button b1, java.awt.Button b2, java.awt.Button b3, java.awt.Button b4)
          Constructs a dialog box with four chosen buttons.
MessageBox(java.awt.Frame parent, java.lang.String title, java.lang.String message, java.awt.Button b1, java.awt.Button b2, java.awt.Button b3, java.awt.Button b4, java.awt.Button b5)
          Constructs a dialog box with five chosen buttons.
MessageBox(java.awt.Frame parent, java.lang.String title, java.lang.String message, java.awt.Button b1, java.awt.Button b2, java.awt.Button b3, java.awt.Button b4, java.awt.Button b5, java.awt.Button b6)
          Constructs a dialog box with six chosen buttons.
MessageBox(java.awt.Frame parent, java.lang.String title, java.lang.String message, java.awt.Button b1, java.awt.Button b2, java.awt.Button b3, java.awt.Button b4, java.awt.Button b5, java.awt.Button b6, java.awt.Button b7)
          Constructs a dialog box with seven chosen buttons.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Tests if the Cancel Button has been clicked.
 java.awt.Button proceed()
          Shows the dialog box and returns the button chosen by the user.
 
Methods inherited from class java.awt.Dialog
, addNotify, conditionalShow, constructComponentName, dispose, getTitle, hide, hideAndDisposeHandler, initIDs, isModal, isResizable, paramString, setModal, setResizable, setTitle, show
 
Methods inherited from class java.awt.Window
addOwnedWindow, addWindowListener, applyResourceBundle, applyResourceBundle, connectOwnedWindow, dispatchEventImpl, eventEnabled, finalize, getFocusOwner, getInputContext, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, isActive, isShowing, nextFocus, ownedInit, pack, postEvent, postProcessKeyEvent, postWindowEvent, preProcessKeyEvent, processEvent, processWindowEvent, readObject, removeOwnedWindow, removeWindowListener, setCursor, setFocusOwner, setWarningString, toBack, toFront, transferFocus, writeObject
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyOrientation, countComponents, deliverEvent, dispatchEventToSelf, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getCursorTarget, getInsets, getLayout, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPrint, list, list, locate, minimumSize, paint, paintComponents, postsOldMouseEvents, preferredSize, print, printComponents, printOneComponent, processContainerEvent, proxyEnableEvents, proxyRequestFocus, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, updateCursor, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getIntrinsicCursor, getLocation, getLocation, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

controlPanel

private java.awt.Panel controlPanel
The zone that contains the buttons.

YES

public static java.awt.Button YES
A Yes Button to give in parameter.

NO

public static java.awt.Button NO
A No Button to give in parameter.

CANCEL

public static java.awt.Button CANCEL
A Cancel Button to give in parameter.

OK

public static java.awt.Button OK
A OK Button to give in parameter.

ABORT

public static java.awt.Button ABORT
A Cancel Button to give in parameter.

RETRY

public static java.awt.Button RETRY
A Retry Button to give in parameter.

IGNORE

public static java.awt.Button IGNORE
A Ignore Button to give in parameter.

nobuttonButton

private static java.awt.Button nobuttonButton
An empty button.

button1

private java.awt.Button button1
Buttons for the dialog box.

button2

private java.awt.Button button2

button3

private java.awt.Button button3

button4

private java.awt.Button button4

button5

private java.awt.Button button5

button6

private java.awt.Button button6

button7

private java.awt.Button button7

buttonReturn

private java.awt.Button buttonReturn
The Button that will be returned.

messageLabel

private java.awt.Label messageLabel
The message in the box.
Constructor Detail

MessageBox

public MessageBox(java.awt.Frame parent,
                  java.lang.String title,
                  java.lang.String message,
                  java.awt.Button b1,
                  java.awt.Button b2,
                  java.awt.Button b3,
                  java.awt.Button b4,
                  java.awt.Button b5,
                  java.awt.Button b6,
                  java.awt.Button b7)
Constructs a dialog box with seven chosen buttons.
Parameters:
parent - a reference on the frame that has called this MessageBox
title - the sentence displayed inthe title bar
message - the message displayed in the dialog box
buttons - b1, b2, b3, b4, b5, b6, b7 are the buttons given in parameter. It is recommended, but not compulsory, that these buttons be among the constants defined in this class.

MessageBox

public MessageBox(java.awt.Frame parent,
                  java.lang.String title,
                  java.lang.String message,
                  java.awt.Button b1,
                  java.awt.Button b2,
                  java.awt.Button b3,
                  java.awt.Button b4,
                  java.awt.Button b5,
                  java.awt.Button b6)
Constructs a dialog box with six chosen buttons.
Parameters:
parent - a reference on the frame that has called this MessageBox
title - the sentence displayed inthe title bar
message - the message displayed in the dialog box
buttons - b1, b2, b3, b4, b5, b6 are the buttons given in parameter. It is recommended, but not compulsory, that these buttons be among the constants defined in this class.

MessageBox

public MessageBox(java.awt.Frame parent,
                  java.lang.String title,
                  java.lang.String message,
                  java.awt.Button b1,
                  java.awt.Button b2,
                  java.awt.Button b3,
                  java.awt.Button b4,
                  java.awt.Button b5)
Constructs a dialog box with five chosen buttons.
Parameters:
parent - a reference on the frame that has called this MessageBox
title - the sentence displayed inthe title bar
message - the message displayed in the dialog box
buttons - b1, b2, b3, b4, b5 are the buttons given in parameter. It is recommended, but not compulsory, that these buttons be among the constants defined in this class.

MessageBox

public MessageBox(java.awt.Frame parent,
                  java.lang.String title,
                  java.lang.String message,
                  java.awt.Button b1,
                  java.awt.Button b2,
                  java.awt.Button b3,
                  java.awt.Button b4)
Constructs a dialog box with four chosen buttons.
Parameters:
parent - a reference on the frame that has called this MessageBox
title - the sentence displayed inthe title bar
message - the message displayed in the dialog box
buttons - b1, b2, b3, b4 are the buttons given in parameter. It is recommended, but not compulsory, that these buttons be among the constants defined in this class.

MessageBox

public MessageBox(java.awt.Frame parent,
                  java.lang.String title,
                  java.lang.String message,
                  java.awt.Button b1,
                  java.awt.Button b2,
                  java.awt.Button b3)
Constructs a dialog box with three chosen buttons.
Parameters:
parent - a reference on the frame that has called this MessageBox
title - the sentence displayed inthe title bar
message - the message displayed in the dialog box
buttons - b1, b2, b3 are the buttons given in parameter. It is recommended, but not compulsory, that these buttons be among the constants defined in this class.

MessageBox

public MessageBox(java.awt.Frame parent,
                  java.lang.String title,
                  java.lang.String message,
                  java.awt.Button b1,
                  java.awt.Button b2)
Constructs a dialog box with two chosen buttons.
Parameters:
parent - a reference on the frame that has called this MessageBox
title - the sentence displayed inthe title bar
message - the message displayed in the dialog box
buttons - b1, b2 are the buttons given in parameter. It is recommended, but not compulsory, that these buttons be among the constants defined in this class.

MessageBox

public MessageBox(java.awt.Frame parent,
                  java.lang.String title,
                  java.lang.String message,
                  java.awt.Button b1)
Constructs a dialog box with one chosen button.
Parameters:
parent - a reference on the frame that has called this MessageBox
title - the sentence displayed inthe title bar
message - the message displayed in the dialog box
buttons - b1 are the buttons given in parameter. It is recommended, but not compulsory, that these buttons be among the constants defined in this class.
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Tests if the Cancel Button has been clicked. In that case, stops the thread and closes the dialog box.
Specified by:
actionPerformed in interface java.awt.event.ActionListener

proceed

public java.awt.Button proceed()
Shows the dialog box and returns the button chosen by the user.
Returns:
the button clicked by the user