AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
showConfirmDialog (Object comp, String message [, String title [, Object options [, Object type]]]) yoix.swing
 
Pops up a modal dialog that displays message, includes a series of buttons that can be used for input, is positioned over comp, which should be an AWT or Swing component, or centered on your screen when comp is NULL, and returns an int that indicates which button the user pressed. The optional title argument is used as the dialog's title when it is not NULL. The optional options argument should be one of DEFAULT_OPTION, OK_CANCEL_OPTION, YES_NO_OPTION, or YES_NO_CANCEL_OPTION (the default), which are integers that are defined in yoix.swing, a String or an Array of strings that are used the labels for the buttons displayed by the dialog. The optional type argument should be ERROR_MESSAGE, INFORMATION_MESSAGE, PLAIN_MESSAGE, QUESTION_MESSAGE (the default), or WARNING_MESSAGE, which are integers that are defined in yoix.swing, or an Image that is displayed in the dialog instead of the default icon that is selected when type is an int.

A return value of -1 means the user closed the dialog without pressing a button. Otherwise the value will be a non-negative integer that indicates which button was pressed, with 0 being the first button in the series displayed by the dialog (undoubtedly the leftmost button). For example, two buttons are displayed when options is OK_CANCEL so a return value of 1 means cancel, but change options to YES_NO_CANCEL_OPTION and three buttons appear and in this case return value would mean no.
 
 Example:   Here is a simple program
import yoix.*.*;

String loop = "How many times to you want to loop?";
String press = "Press any button and see what happens";
String answer;
int    result;
int    counter = 1;

if ((answer = showInputDialog(NULL, loop)) != NULL)
    counter = atoi(answer);

while (counter-- > 0) {
    if ((result = showConfirmDialog(NULL, press)) >= 0) 
        press = "Last time through you pressed button " +
            toString(result);
    else press = "Last time through you closed the window";
    press += "\n     counter=" + toString(counter);
}

showMessageDialog(NULL, "The counter reached 0 - we're all done");
that uses showConfirmDialog, showInputDialog, and showMessageDialog.
 
 Return:   int
 
 See Also:   showInputDialog, showMessageDialog

 

Yoix is a registered trademark of AT&T Inc.