jbcl.control Package
java.lang.Object +----com.borland.jbcl.control.Message
Variables Constructors Properties Methods Event Listeners
Implements WindowListener, Serializable, EventListener
A message box component that displays a text message of your choice and includes a set of buttons the user uses to respond to the message.
To set the message in the message box, set the message
property to the string you want to display. The title
property contains the text that appears on the title bar of the message box's frame.
The buttonSet
property determines which buttons appear in the dialog box. The following button sets are available:
OK | "OK" button. |
YES | "Yes" button. |
NO | "No" button |
CANCEL | "Cancel" button |
OK_CANCEL | "OK" and "Cancel" buttons |
YES_NO | "Yes" and "No" buttons |
YES_NO_CANCEL | "Yes", "No", and "Cancel" buttons |
When the user selects one of the buttons, its value is stored in the result
property. For example, if the user chooses OK, the value of result
property becomes OK.
If you prefer to have other labels on the buttons other than the standard OK, Yes, No, and Cancel strings, you can specify your own labels with the labels
property. The first string in the labels array becomes the label of the first button in the message box, the second string becomes the label of the second button, and so on.
You can make the Message
component appear at design time:
Message
component on the UI Designer or on the Component Tree.
frame
property to this in the Component Inspector.
visible
property to true.
To make the message box appear at runtime, call the show()
method or set the visible
property to true.
protected transient ActionMulticaster actionMulticaster
protected int buttonSetRepresents which button set to show. The int constants are listed in the table above.
public static final int CANCEL = ButtonDialog.CANCELA constant to represent the button set consisting of the "Cancel" button.
protected MessageDialog dialogThe
MessageDialog
object used for the message box.
protected Frame frameThe parent frame for the message box.
protected String[] labelsThe text to show on the buttons. The underlying buttons are still the standard buttons, functionally, such as "Yes", "No", and "Cancel", but the visible text can be changed, such as to another spoken language.
protected String messageThe message to show in the message box.
public static final int NO = ButtonDialog.NOA constant to represent the button set consisting of the "No" button.
public static final int OK = ButtonDialog.OKA constant to represent the button set consisting of the "OK" button.
public static final int OK_CANCEL = ButtonDialog.OK_CANCELA constant to represent the button set consisting of the "OK" and "Cancel" buttons.
protected int resultWhich button was clicked.
protected String titleThe title-bar text of the message box.
public static final int YES = ButtonDialog.YESA constant to represent the button set consisting of the "Yes" button.
public static final int YES_NO = ButtonDialog.YES_NOA constant to represent the button set consisting of the "Yes" and "No" buttons.
public static final int YES_NO_CANCEL = ButtonDialog.YES_NO_CANCELA constant to represent the button set consisting of the "Yes", "No", and "Cancel" buttons.
public Message()Constructs a message box with no parent frame, title-bar text, or message string.
public Message(Frame frame)Constructs a message box with the specified parent frame, no title-bar text, and no message string.
Parameters:
frame
public Message(Frame frame, String title)Constructs a message box with the specified parent frame and title-bar text, and no message string.
Parameters:
frame
title
public Message(Frame frame, String title, String msg)Constructs a message box.
Parameters:
frame
title
msg
public int getButtonSet() public void setButtonSet(int bs)Determines which buttons appear in the message box. These are the possible button sets:
OK | "OK" button. |
YES | "Yes" button. |
NO | "No" button |
CANCEL | "Cancel" button |
OK_CANCEL | "OK" and "Cancel" buttons |
YES_NO | "Yes" and "No" buttons |
YES_NO_CANCEL | "Yes", "No", and "Cancel" buttons |
public Frame getFrame() public void setFrame(Frame frame)Determines the parent frame for the message box.
public String[] getLabels() public void setLabels(String[] l)Determines the text that appears on the buttons. If no value is assigned, the standard OK, Cancel, Yes, or No strings appear. The first string in the array of
Strings
becomes the label on
the first button in the message box. The second string becomes the label on the second button, and so on.
public String getMessage() public void setMessage(String message)The message string to display in the message box.
public int getResult() public void setResult(int i)Stores the user's choice of buttons to respond to the message box. For example, if the user chooses the OK button, the value of
result
becomes OK.
The value must be one of the com.borland.jbcl.control.Message
variables.
public String getTitle() public void setTitle(String title)Determines the text that appears on the title bar, if any.
public boolean isVisible() public void setVisible(boolean visible)Determines whether the message box is visible. If true, the message box is visible onscreen; if false, it isn't visible. The
show()
method sets the visible property to true.
public void show()Displays the message box by setting the
visible
property to true.
public void addActionListener(ActionListener l) public void removeActionListener(ActionListener l)