net.sourceforge.jiu.gui.awt.dialogs

Class YesNoDialog

Implemented Interfaces:
ActionListener

public class YesNoDialog
extends Dialog
implements ActionListener

A dialog that asks a question and offers a Yes and a No button (and optionally a Cancel button).
Author:
Marco Schmidt
Since:
0.11.0

Field Summary

static int
RESULT_CANCEL
Will be returned in getResult() if the CANCEL button was chosen.
static int
RESULT_NO
Will be returned in getResult() if the NO button was chosen.
static int
RESULT_YES
Will be returned in getResult() if the YES button was chosen.
private Button
cancel
private Button
no
private int
result
private Button
yes

Constructor Summary

YesNoDialog(Frame owner, Strings strings, int titleIndex, int questionIndex, boolean includeCancel)
Creates a new YesNoDialog object and shows it centered on the screen.

Method Summary

void
actionPerformed(ActionEvent e)
Hides (closes) this dialog if the OK button was source of the action event (e.g.
int
getResult()
Returns one of the RESULT_xyz constants of this class.

Field Details

RESULT_CANCEL

public static final int RESULT_CANCEL
Will be returned in getResult() if the CANCEL button was chosen.
Field Value:
2

RESULT_NO

public static final int RESULT_NO
Will be returned in getResult() if the NO button was chosen.
Field Value:
1

RESULT_YES

public static final int RESULT_YES
Will be returned in getResult() if the YES button was chosen.
Field Value:
0

cancel

private Button cancel

no

private Button no

result

private int result

yes

private Button yes

Constructor Details

YesNoDialog

public YesNoDialog(Frame owner,
                   Strings strings,
                   int titleIndex,
                   int questionIndex,
                   boolean includeCancel)
Creates a new YesNoDialog object and shows it centered on the screen.
Parameters:
owner - the frame that owns this modal dialog
strings - the String resources
titleIndex - the index into the String resource of the title text
questionIndex - the index into the String resource of the question text
includeCancel - determines whether a third button 'Cancel' will be included

Method Details

actionPerformed

public void actionPerformed(ActionEvent e)
Hides (closes) this dialog if the OK button was source of the action event (e.g. if the button was pressed).

getResult

public int getResult()
Returns one of the RESULT_xyz constants of this class.
Returns:
the RESULT constant of the button which the user has chosen