Class AlertListener
java.lang.Object
|
+--AlertListener
- public class AlertListener
- extends java.lang.Object
- implements java.awt.event.ActionListener, java.awt.event.FocusListener
Implements a listener that works specifically for the alert dialog
generated by AlertListener.alert() Just a handy way of making a
standard application alert and receiving the info about which button
was clicked.
Constructor Summary |
(package private) |
AlertListener(java.awt.Dialog _d)
Standard constructor, takes the dialog box to listen to. |
Method Summary |
void |
actionPerformed(java.awt.event.ActionEvent e)
Executed when one of the buttons is clicked. |
static boolean |
alert(java.lang.String mesg,
java.lang.String label1,
java.lang.String label2,
java.awt.Frame f)
Creates a single message two button alert dialog box, and returns
true if the first button is selected, false if the second is. |
boolean |
answer()
Returns the result of the dialog box. |
void |
focusGained(java.awt.event.FocusEvent e)
|
void |
focusLost(java.awt.event.FocusEvent e)
|
Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
AlertListener
AlertListener(java.awt.Dialog _d)
- Standard constructor, takes the dialog box to listen to. This box
needs to have two buttons, with action commands button1 and
button2.
- Parameters:
_d
- the alert to listen to
answer
public boolean answer()
- Returns the result of the dialog box.
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
- Executed when one of the buttons is clicked. Sets the return
value accordingly.
- Specified by:
- actionPerformed in interface java.awt.event.ActionListener
- Parameters:
e
- the actionevent that occured
focusGained
public void focusGained(java.awt.event.FocusEvent e)
- Specified by:
- focusGained in interface java.awt.event.FocusListener
focusLost
public void focusLost(java.awt.event.FocusEvent e)
- Specified by:
- focusLost in interface java.awt.event.FocusListener
alert
public static boolean alert(java.lang.String mesg,
java.lang.String label1,
java.lang.String label2,
java.awt.Frame f)
- Creates a single message two button alert dialog box, and returns
true if the first button is selected, false if the second is. The
dialog box halts the program and disappears after a selection is
made.
- Parameters:
mesg
- the message to displaylabel1
- the label of the first buttonlabel2
- the label of the second buttonw
- the window the dialog is for- Returns:
- a boolean indicating which button was selected