Class MsgDialog

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

public class MsgDialog
extends Dialog
implements ActionListener
This class mimics the MessageBox API from Windows It can be used for notifying short message to the user or for debugging purpose

Here is how to use this class :
int ret = MsgDialog.msg( ... valid argument list ...)
There are many overloaded methods for msg, please refer to the doc below.

The dialog size if arbitrary fixed to maximum 1/3 of screen size If the message is longer than the availabe space, it is displayed using multiple lines. Lines are cutted at SPACE character only

Version:
1.0 February 1998
Author:
Sébastien Stormacq works as Software Engineer for AmbraSoft sa,
a company based in Luxembourg, specialized in client server development.
His main interests are Internet/Intranet technologies and object oriented development.
Sebastien Stormacq is a Sun Certified Java Programmer.
You can reach him by email at sst@ambrasoft.lu

Variable Index

 o ICON_INFORMATION
Icon to display : an "Information" sign
 o ICON_MULTI_CENTER
 o ICON_MULTI_LEFT
 o ICON_NONE
Do not display an icon
 o ICON_STOP
Icon to display : an "STOP" sign
 o ICON_WARNING
Icon to display : an "Warning" sign
 o ID_CANCEL
Return value : the user pressed the "Cancel" button
 o ID_NO
Return value : the user pressed the "No" button
 o ID_OK
Return value : the user pressed the "Ok" button
 o ID_RETRY
Return value : the user pressed the "Retry" button
 o ID_YES
Return value : the user pressed the "Yes" button
 o MB_CANCEL
Style constant : displays a single button labelled "Cancel"
 o MB_NO
Style constant : displays a single button labelled "No"
 o MB_OK
Style constant : displays a single button labelled "Ok"
 o MB_OKCANCEL
Style constant : displays two buttons labelled "Ok" and "Cancel"
 o MB_OKCANCELRETRY
Style constant : displays three buttons labelled "Ok","Cancel" and "Retry"
 o MB_RETRY
Style constant : displays a single button labelled "Retry"
 o MB_YES
Style constant : displays a single button labelled "Yes"
 o MB_YESNO
Style constant : displays two buttons labelled "Yes" and "No"

Method Index

 o actionPerformed(ActionEvent)
 o getRetValue()
Give the return value of the dialog.
 o msg(Frame, String)
This method displays a simple message with no title and no icon.
 o msg(Frame, String, int)
This method displays a dialog without title and without icon.
 o msg(Frame, String, int, int)
This method displays a dialog without title.
 o msg(Frame, String, String, int)
This method displays a dialog without icon.
 o msg(Frame, String, String, int, int)
This method displays a dialog to the user
 o msg(String)
This method displays a dialog a simple message.
 o msg(String, int)
This method displays a dialog without icon and without title.
 o msg(String, String, int)
This method displays a dialog without icon.
 o msg(String, String, int, int)
This method displays a dialog to the user.
 o parseStr(String, String)
 o setBackground(Color)

Variables

 o MB_RETRY
 public static final int MB_RETRY
Style constant : displays a single button labelled "Retry"

 o MB_NO
 public static final int MB_NO
Style constant : displays a single button labelled "No"

 o MB_YES
 public static final int MB_YES
Style constant : displays a single button labelled "Yes"

 o MB_OK
 public static final int MB_OK
Style constant : displays a single button labelled "Ok"

 o MB_CANCEL
 public static final int MB_CANCEL
Style constant : displays a single button labelled "Cancel"

 o MB_YESNO
 public static final int MB_YESNO
Style constant : displays two buttons labelled "Yes" and "No"

 o MB_OKCANCEL
 public static final int MB_OKCANCEL
Style constant : displays two buttons labelled "Ok" and "Cancel"

 o MB_OKCANCELRETRY
 public static final int MB_OKCANCELRETRY
Style constant : displays three buttons labelled "Ok","Cancel" and "Retry"

 o ID_YES
 public static final int ID_YES
Return value : the user pressed the "Yes" button

 o ID_NO
 public static final int ID_NO
Return value : the user pressed the "No" button

 o ID_CANCEL
 public static final int ID_CANCEL
Return value : the user pressed the "Cancel" button

 o ID_OK
 public static final int ID_OK
Return value : the user pressed the "Ok" button

 o ID_RETRY
 public static final int ID_RETRY
Return value : the user pressed the "Retry" button

 o ICON_NONE
 public static final int ICON_NONE
Do not display an icon

 o ICON_INFORMATION
 public static final int ICON_INFORMATION
Icon to display : an "Information" sign

 o ICON_STOP
 public static final int ICON_STOP
Icon to display : an "STOP" sign

 o ICON_WARNING
 public static final int ICON_WARNING
Icon to display : an "Warning" sign

 o ICON_MULTI_CENTER
 public static final int ICON_MULTI_CENTER
 o ICON_MULTI_LEFT
 public static final int ICON_MULTI_LEFT

Methods

 o msg
 public static int msg(Frame parent,
                       String title,
                       String msg,
                       int style,
                       int icon)
This method displays a dialog to the user

Parameters:
Frame - the parent window of the dialog, this frame will receive the focus when the user exits the dialog
String - the title of the dialog
String - the message to be displayed
int - the style of the dialog, ie. one of the MB_XXX constants. These can be added
int - the icon to use, see the ICON_XXX constants
Returns:
int the id of the button pressed by the user
See Also:
MB_OK, MB_CANCEL, MB_YES, MB_NO, MB_RETRY, ID_OK, ID_YES, ID_NO, ID_CANCEL, ID_RETRY, ICON_STOP, ICON_INFORMATION, ICON_WARNING
 o msg
 public static int msg(Frame parent,
                       String msg,
                       int style,
                       int icon)
This method displays a dialog without title. It is equivalent to give an empty title as parameter

Parameters:
Frame - the parent window of the dialog, this frame will receive the focus when the user exits the dialog
String - the message to be displayed
int - the style of the dialog, ie. on eof the MB_XXX constants. These can be added
int - the icon to use, see the ICON_XXX constants
Returns:
int the id of the button pressed by the user
See Also:
msg
 o msg
 public static int msg(Frame parent,
                       String title,
                       String msg,
                       int style)
This method displays a dialog without icon. It is equivalent to give the NO_ICON parameter

Parameters:
Frame - the parent window of the dialog, this frame will receive the focus when the user exits the dialog
String - the title of the dialog
String - the message to be displayed
int - the style of the dialog, ie. on eof the MB_XXX constants. These can be added
Returns:
int the id of the button pressed by the user
See Also:
msg
 o msg
 public static int msg(Frame parent,
                       String msg,
                       int style)
This method displays a dialog without title and without icon. It is equivalent to give an empty title and the NO_ICON parameters

Parameters:
Frame - the parent window of the dialog, this frame will receive the focus when the user exits the dialog
String - the message to be displayed
int - the style of the dialog, ie. on eof the MB_XXX constants. These can be added
Returns:
int the id of the button pressed by the user
See Also:
msg
 o msg
 public static int msg(Frame parent,
                       String msg)
This method displays a simple message with no title and no icon. It is equivalent to give an empty title and the NO_ICON parameters. The default style is MB_OK

Parameters:
Frame - the parent window of the dialog, this frame will receive the focus when the user exits the dialog
String - the message to be displayed
Returns:
int the id of the button pressed by the user
See Also:
msg
 o msg
 public static int msg(String title,
                       String msg,
                       int style,
                       int icon)
This method displays a dialog to the user. A default parent frame is created

Parameters:
String - the title of teh dialog
String - the message to be displayed
int - the style of the dialog, ie. on eof the MB_XXX constants. These can be added
int - the icon to use, see the ICON_XXX constants
Returns:
int the id of the button pressed by the user
See Also:
msg
 o msg
 public static int msg(String title,
                       String msg,
                       int style)
This method displays a dialog without icon. It is equivalent to give the NO_ICON parameter. A default parent frame is created.

Parameters:
String - the title of the dialog
String - the message to be displayed
int - the style of the dialog, ie. on eof the MB_XXX constants. These can be added
Returns:
int the id of the button pressed by the user
See Also:
msg
 o msg
 public static int msg(String msg,
                       int style)
This method displays a dialog without icon and without title. It is equivalent to give the NO_ICON parameter and to give an empty title. A default parent frame is created

Parameters:
String - the message to be displayed
int - the style of the dialog, ie. on eof the MB_XXX constants. These can be added
Returns:
int the id of the button pressed by the user
See Also:
msg
 o msg
 public static int msg(String msg)
This method displays a dialog a simple message. A default parent frame is created. This dialog has no title and no icon, its style is MB_OK. This is the quickest way to display a simple message to the user.

Parameters:
String - the message to be displayed
Returns:
int the id of the button pressed by the user
See Also:
msg
 o parseStr
 public static String[] parseStr(String stref,
                                 String delim)
 o getRetValue
 public int getRetValue()
Give the return value of the dialog. The return value indicates the button used to exit the dialog

Values can be :

 o setBackground
 public void setBackground(Color c)
Overrides:
setBackground in class Component
 o actionPerformed
 public void actionPerformed(ActionEvent ae)