de.cgarbs.awt
Class MessageBox

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

public class MessageBox
extends java.awt.Dialog

Displays a simple modal message box on the screen waiting for the user to click a button. Compatible with JAVA[tm] 1.0 The button's IDs can either be used directly (OKHELP or YESNOHELP) or you can create your own combinations by ORing IDs (OK | NO | HELP). This class is licensed under the GNU LESSER GENERAL PUBLIC LICENSE.

Version:
0.0.1
Author:
Christian Garbs
See Also:
Serialized Form

Field Summary
protected  java.awt.Panel buttonPanel
          This panel contains the buttons.
protected  java.awt.Button cancel
          This is the button labeled "cancel".
static int CANCEL
          The ID of just a cancel button.
protected  java.awt.Button help
          This is the button labeled "help".
static int HELP
          The ID of just a help button.
protected  java.awt.Button no
          This is the button labeled "no".
static int NO
          The ID of just a no button.
protected  java.awt.Button ok
          This is the button labeled "ok".
static int OK
          The ID of just an ok button.
static int OKCANCEL
          The ID of an ok and a cancel button.
static int OKCANCELHELP
          The ID of an ok, a cancel and a help button.
static int OKHELP
          The ID of an ok and a help button.
protected  int pressed
          Sums up the IDs of all pressed buttons.
static int SPLASH
          The ID of a splash screen (a window with no buttons, the MessageBox should remove the MessageBox by itself).
protected  java.awt.TextArea text
          This TextArea contains the message to be displayed.
protected  java.awt.Button yes
          This is the button labeled "yes".
static int YES
          The ID of just a yes button.
static int YESNO
          The ID of a yes and a no button.
static int YESNOHELP
          The ID of a yes, a no and a help button.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
MessageBox(java.awt.Frame parent, java.lang.String message)
          Displays a new MessageBox with only an ok button and an empty title.
MessageBox(java.awt.Frame parent, java.lang.String message, java.lang.String title)
          Displays a new MessageBox with only an ok button.
MessageBox(java.awt.Frame parent, java.lang.String message, java.lang.String title, int buttons)
          Displays a new MessageBox.
MessageBox(java.lang.String message)
          Displays a new MessageBox with only an ok button and an empty title without parent Frame.
MessageBox(java.lang.String message, java.lang.String title)
          Displays a new MessageBox with only an ok button without parent Frame.
MessageBox(java.lang.String message, java.lang.String title, int buttons)
          Displays a new MessageBox with no parent Frame.
 
Method Summary
 boolean action(java.awt.Event e, java.lang.Object o)
          Deprecated. As of JDK 1.1 ActionListeners should be used (but aren't in this class).
 boolean handleEvent(java.awt.Event e)
          Deprecated. As of JDK 1.1 processEvent() should be used (but isn't in this class).
 boolean isCancel()
          Checks if the button cancel has been pressed.
 boolean isHelp()
          Checks if the button help has been pressed.
 boolean isNo()
          Checks if the button no has been pressed.
 boolean isNothing()
          Checks if no button was pressed (eg. the window was closed using window controls).
 boolean isOk()
          Checks if the button ok has been pressed.
 boolean isYes()
          Checks if the button yes has been pressed.
static void main(java.lang.String[] args)
          A demonstration of this class.
 
Methods inherited from class java.awt.Dialog
addNotify, dispose, getTitle, hide, isModal, isResizable, paramString, setModal, setResizable, setTitle, show
 
Methods inherited from class java.awt.Window
addWindowListener, applyResourceBundle, applyResourceBundle, finalize, getFocusOwner, getInputContext, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, isShowing, pack, postEvent, processEvent, processWindowEvent, removeWindowListener, setCursor, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, 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, wait, wait, wait
 

Field Detail

SPLASH

public static final int SPLASH
The ID of a splash screen (a window with no buttons, the MessageBox should remove the MessageBox by itself).

OK

public static final int OK
The ID of just an ok button.

CANCEL

public static final int CANCEL
The ID of just a cancel button.

HELP

public static final int HELP
The ID of just a help button.

YES

public static final int YES
The ID of just a yes button.

NO

public static final int NO
The ID of just a no button.

OKCANCEL

public static final int OKCANCEL
The ID of an ok and a cancel button.

OKHELP

public static final int OKHELP
The ID of an ok and a help button.

OKCANCELHELP

public static final int OKCANCELHELP
The ID of an ok, a cancel and a help button.

YESNO

public static final int YESNO
The ID of a yes and a no button.

YESNOHELP

public static final int YESNOHELP
The ID of a yes, a no and a help button.

pressed

protected int pressed
Sums up the IDs of all pressed buttons.

ok

protected java.awt.Button ok
This is the button labeled "ok".

cancel

protected java.awt.Button cancel
This is the button labeled "cancel".

help

protected java.awt.Button help
This is the button labeled "help".

yes

protected java.awt.Button yes
This is the button labeled "yes".

no

protected java.awt.Button no
This is the button labeled "no".

text

protected java.awt.TextArea text
This TextArea contains the message to be displayed.

buttonPanel

protected java.awt.Panel buttonPanel
This panel contains the buttons.
Constructor Detail

MessageBox

public MessageBox(java.lang.String message)
Displays a new MessageBox with only an ok button and an empty title without parent Frame.
Parameters:
message - The message to be displayed.

MessageBox

public MessageBox(java.lang.String message,
                  java.lang.String title)
Displays a new MessageBox with only an ok button without parent Frame.
Parameters:
message - The message to be displayed.
title - The title of this MessageBox.

MessageBox

public MessageBox(java.lang.String message,
                  java.lang.String title,
                  int buttons)
Displays a new MessageBox with no parent Frame.
Parameters:
message - The message to be displayed.
title - The title of this MessageBox.
buttons - The ID of the buttons to show.

MessageBox

public MessageBox(java.awt.Frame parent,
                  java.lang.String message)
Displays a new MessageBox with only an ok button and an empty title.
Parameters:
parent - The parent Frame of this MessageBox.
message - The message to be displayed.

MessageBox

public MessageBox(java.awt.Frame parent,
                  java.lang.String message,
                  java.lang.String title)
Displays a new MessageBox with only an ok button.
Parameters:
parent - The parent Frame of this MessageBox.
message - The message to be displayed.
title - The title of this MessageBox.

MessageBox

public MessageBox(java.awt.Frame parent,
                  java.lang.String message,
                  java.lang.String title,
                  int buttons)
Displays a new MessageBox.
Parameters:
parent - The parent Frame of this MessageBox.
message - The message to be displayed.
title - The title of this MessageBox.
buttons - The ID of the buttons to show.
Method Detail

action

public boolean action(java.awt.Event e,
                      java.lang.Object o)
Deprecated. As of JDK 1.1 ActionListeners should be used (but aren't in this class).

Handles any actions within this class.
Overrides:
action in class java.awt.Component
Parameters:
e -  
o -  

handleEvent

public boolean handleEvent(java.awt.Event e)
Deprecated. As of JDK 1.1 processEvent() should be used (but isn't in this class).

Handles any events within this class.
Overrides:
handleEvent in class java.awt.Component
Parameters:
e -  

isOk

public boolean isOk()
Checks if the button ok has been pressed.
Returns:
true if the button ok has been pressed.

isCancel

public boolean isCancel()
Checks if the button cancel has been pressed.
Returns:
true if the button cancel has been pressed.

isYes

public boolean isYes()
Checks if the button yes has been pressed.
Returns:
true if the button yes has been pressed.

isNo

public boolean isNo()
Checks if the button no has been pressed.
Returns:
true if the button no has been pressed.

isHelp

public boolean isHelp()
Checks if the button help has been pressed.
Returns:
true if the button help has been pressed.

isNothing

public boolean isNothing()
Checks if no button was pressed (eg. the window was closed using window controls).
Returns:
true if no button was pressed

main

public static void main(java.lang.String[] args)
A demonstration of this class. Run it by executing the class itself.
Parameters:
args - command line arguments (unused)