javabook
Class ResponseBox

java.lang.Object
  extended byjavabook.JavaBookDialog
      extended byjavabook.ResponseBox

public class ResponseBox
extends JavaBookDialog

This dialog is for prompting a yes-no response from the user. This dialog allows the programmer to add a single line of prompt with two standard Yes and No buttons. Optionally, the dialog can be adjusted to have one, two, or three buttons with programmer-designated button labels. Buttons are identified by the constants BUTTON1, BUTTON2, and BUTTON3. For the standard two-button dialog, BUTTON1 and BUTTON2 can also be referred as YES and NO, respectively.

This class is provided as freeware. You are free to use as provided or modify to your heart's content. But you use it at your own risk. No implied or explicit warranty is given.


Field Summary
static int BUTTON1
          The constant for the leftmost button whose value is equal to YES
static int BUTTON2
          The constant for the middle button whose value is equal to NO; this button is rightmost when the dialog has only two buttons
static int BUTTON3
          The constant for the rightmost button whose value is equal to CANCEL
static int CANCEL
          The constant for the CANCEL button
static int NO
          The constant for the NO button
static int YES
          The constant for the YES button
 
Fields inherited from class javabook.JavaBookDialog
ERROR_ICON, INFO_ICON, NO_ICON, QUESTION_ICON, WARNING_ICON
 
Constructor Summary
ResponseBox(java.awt.Frame owner)
          Constructs the standard ResponseBox dialog with two buttons labeled 'Yes' and 'No'.
ResponseBox(java.awt.Frame owner, int buttonCount)
          Constructs this dialog with 'owner' as its owner and buttonCount number of buttons.
 
Method Summary
 int prompt(java.lang.String text)
          Prompts the user and returns the result of user action.
 void setLabel(int id, java.lang.String text)
          Sets the label of the designated button identified by its id value.
 
Methods inherited from class javabook.JavaBookDialog
setIcon, setLocation, setTitle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

YES

public static final int YES
The constant for the YES button

See Also:
Constant Field Values

NO

public static final int NO
The constant for the NO button

See Also:
Constant Field Values

CANCEL

public static final int CANCEL
The constant for the CANCEL button

See Also:
Constant Field Values

BUTTON1

public static final int BUTTON1
The constant for the leftmost button whose value is equal to YES

See Also:
Constant Field Values

BUTTON2

public static final int BUTTON2
The constant for the middle button whose value is equal to NO; this button is rightmost when the dialog has only two buttons

See Also:
Constant Field Values

BUTTON3

public static final int BUTTON3
The constant for the rightmost button whose value is equal to CANCEL

See Also:
Constant Field Values
Constructor Detail

ResponseBox

public ResponseBox(java.awt.Frame owner)
Constructs the standard ResponseBox dialog with two buttons labeled 'Yes' and 'No'. Use setLabel to change the button label.

Parameters:
owner - a Frame object owner of this dialog

ResponseBox

public ResponseBox(java.awt.Frame owner,
                   int buttonCount)
Constructs this dialog with 'owner' as its owner and buttonCount number of buttons. Valid values for buttonCount is 1, 2, or 3.

Parameters:
owner - a Frame object owner of this dialog
buttonCount - the number of buttons this dialog has
Method Detail

prompt

public int prompt(java.lang.String text)
Prompts the user and returns the result of user action.

Parameters:
text - the prompt message to display
Returns:
the value that indicates the user action

setLabel

public void setLabel(int id,
                     java.lang.String text)
Sets the label of the designated button identified by its id value.

Parameters:
id - the id of the button
text - the new label the button