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
-
ICON_INFORMATION
- Icon to display : an "Information" sign
-
ICON_MULTI_CENTER
-
-
ICON_MULTI_LEFT
-
-
ICON_NONE
- Do not display an icon
-
ICON_STOP
- Icon to display : an "STOP" sign
-
ICON_WARNING
- Icon to display : an "Warning" sign
-
ID_CANCEL
- Return value : the user pressed the "Cancel" button
-
ID_NO
- Return value : the user pressed the "No" button
-
ID_OK
- Return value : the user pressed the "Ok" button
-
ID_RETRY
- Return value : the user pressed the "Retry" button
-
ID_YES
- Return value : the user pressed the "Yes" button
-
MB_CANCEL
- Style constant : displays a single button labelled "Cancel"
-
MB_NO
- Style constant : displays a single button labelled "No"
-
MB_OK
- Style constant : displays a single button labelled "Ok"
-
MB_OKCANCEL
- Style constant : displays two buttons labelled "Ok" and "Cancel"
-
MB_OKCANCELRETRY
- Style constant : displays three buttons labelled "Ok","Cancel" and "Retry"
-
MB_RETRY
- Style constant : displays a single button labelled "Retry"
-
MB_YES
- Style constant : displays a single button labelled "Yes"
-
MB_YESNO
- Style constant : displays two buttons labelled "Yes" and "No"
-
actionPerformed(ActionEvent)
-
-
getRetValue()
- Give the return value of the dialog.
-
msg(Frame, String)
- This method displays a simple message with no title and no icon.
-
msg(Frame, String, int)
- This method displays a dialog without title and without icon.
-
msg(Frame, String, int, int)
- This method displays a dialog without title.
-
msg(Frame, String, String, int)
- This method displays a dialog without icon.
-
msg(Frame, String, String, int, int)
- This method displays a dialog to the user
-
msg(String)
- This method displays a dialog a simple message.
-
msg(String, int)
- This method displays a dialog without icon and without title.
-
msg(String, String, int)
- This method displays a dialog without icon.
-
msg(String, String, int, int)
- This method displays a dialog to the user.
-
parseStr(String, String)
-
-
setBackground(Color)
-
MB_RETRY
public static final int MB_RETRY
- Style constant : displays a single button labelled "Retry"
MB_NO
public static final int MB_NO
- Style constant : displays a single button labelled "No"
MB_YES
public static final int MB_YES
- Style constant : displays a single button labelled "Yes"
MB_OK
public static final int MB_OK
- Style constant : displays a single button labelled "Ok"
MB_CANCEL
public static final int MB_CANCEL
- Style constant : displays a single button labelled "Cancel"
MB_YESNO
public static final int MB_YESNO
- Style constant : displays two buttons labelled "Yes" and "No"
MB_OKCANCEL
public static final int MB_OKCANCEL
- Style constant : displays two buttons labelled "Ok" and "Cancel"
MB_OKCANCELRETRY
public static final int MB_OKCANCELRETRY
- Style constant : displays three buttons labelled "Ok","Cancel" and "Retry"
ID_YES
public static final int ID_YES
- Return value : the user pressed the "Yes" button
ID_NO
public static final int ID_NO
- Return value : the user pressed the "No" button
ID_CANCEL
public static final int ID_CANCEL
- Return value : the user pressed the "Cancel" button
ID_OK
public static final int ID_OK
- Return value : the user pressed the "Ok" button
ID_RETRY
public static final int ID_RETRY
- Return value : the user pressed the "Retry" button
ICON_NONE
public static final int ICON_NONE
- Do not display an icon
ICON_INFORMATION
public static final int ICON_INFORMATION
- Icon to display : an "Information" sign
ICON_STOP
public static final int ICON_STOP
- Icon to display : an "STOP" sign
ICON_WARNING
public static final int ICON_WARNING
- Icon to display : an "Warning" sign
ICON_MULTI_CENTER
public static final int ICON_MULTI_CENTER
ICON_MULTI_LEFT
public static final int ICON_MULTI_LEFT
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
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
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
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
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
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
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
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
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
parseStr
public static String[] parseStr(String stref,
String delim)
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 :
- ID_NONE : the user pressed the ESC key or use the close button
- ID_OK : the user pressed the Ok button
- ID_CANCEL : the user pressed the Cancel button
- ID_YES : the user pressed the Yes button
- ID_NO : the user pressed the No button
- ID_RETRY : the user pressed the Retry button
setBackground
public void setBackground(Color c)
- Overrides:
- setBackground in class Component
actionPerformed
public void actionPerformed(ActionEvent ae)