|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--erkka.MessageBox
Provides a reusable window that presents a message and choice buttons to the user. A modal dialog is used. Since a thread is used to set the dialog to visible, when the client calls ask() it will not block. The client may implement ActionListener, which has: public void actionPerformed(ActionEvent evt) if user response notification is desired.
Constructor Summary | |
MessageBox()
This constructor is used for no listener, such as for a simple okay dialog. |
|
MessageBox(java.awt.event.ActionListener listener)
This convenience constructor is used to delare the listener that will be notified when a button is clicked. |
Method Summary | |
void |
actionPerformed(java.awt.event.ActionEvent evt)
|
void |
addChoice(java.lang.String label)
A convenience method that assumes the command is the same as the label. |
void |
addChoice(java.lang.String label,
char mnenomic)
|
void |
addChoice(java.lang.String label,
java.lang.String command)
|
void |
ask(java.lang.String message)
One of the "ask" methods must be the last call when using a MessageBox. |
void |
askOkay(java.lang.String message)
Same as ask(String message) except adds an "Okay" button. |
void |
askYesNo(java.lang.String message)
Same as ask(String message) except adds "Yes" and "No" buttons. |
void |
keyType(java.awt.event.KeyEvent evt)
|
static void |
main(java.lang.String[] args)
|
void |
run()
This prevents the caller from blocking on ask(), which if this class is used on an awt event thread would cause a deadlock. |
void |
setActionListener(java.awt.event.ActionListener listener)
This set the listener to be notified of button clicks and WindowClosing events. |
void |
setCloseWindowCommand(java.lang.String command)
Sets the ActionCommand used in the ActionEvent when the user attempts to close the window. |
void |
setFrame(javax.swing.JFrame frame)
If a Frame is provided then it is used to instantiate the modal Dialog. |
void |
setTitle(java.lang.String title)
|
void |
useImageCanvas(java.awt.Canvas imageCanvas)
This is handy for providing a small image that will be displayed to the left of the message. |
void |
useImageCanvas(java.lang.String fileName)
This loads the image from the specified @param fileName, which must be in the same directory as this class. |
void |
windowActivated(java.awt.event.WindowEvent evt)
|
void |
windowClosed(java.awt.event.WindowEvent evt)
|
void |
windowClosing(java.awt.event.WindowEvent evt)
|
void |
windowDeactivated(java.awt.event.WindowEvent evt)
|
void |
windowDeiconified(java.awt.event.WindowEvent evt)
|
void |
windowIconified(java.awt.event.WindowEvent evt)
|
void |
windowOpened(java.awt.event.WindowEvent evt)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public MessageBox(java.awt.event.ActionListener listener)
public MessageBox()
Method Detail |
public static void main(java.lang.String[] args)
public void run()
run
in interface java.lang.Runnable
public void actionPerformed(java.awt.event.ActionEvent evt)
actionPerformed
in interface java.awt.event.ActionListener
public void windowClosing(java.awt.event.WindowEvent evt)
windowClosing
in interface java.awt.event.WindowListener
public void windowClosed(java.awt.event.WindowEvent evt)
windowClosed
in interface java.awt.event.WindowListener
public void windowDeiconified(java.awt.event.WindowEvent evt)
windowDeiconified
in interface java.awt.event.WindowListener
public void windowIconified(java.awt.event.WindowEvent evt)
windowIconified
in interface java.awt.event.WindowListener
public void windowOpened(java.awt.event.WindowEvent evt)
windowOpened
in interface java.awt.event.WindowListener
public void windowActivated(java.awt.event.WindowEvent evt)
windowActivated
in interface java.awt.event.WindowListener
public void windowDeactivated(java.awt.event.WindowEvent evt)
windowDeactivated
in interface java.awt.event.WindowListener
public void keyType(java.awt.event.KeyEvent evt)
public void setActionListener(java.awt.event.ActionListener listener)
public void setTitle(java.lang.String title)
public void setFrame(javax.swing.JFrame frame)
public void setCloseWindowCommand(java.lang.String command)
public void useImageCanvas(java.awt.Canvas imageCanvas)
public void useImageCanvas(java.lang.String fileName)
public void addChoice(java.lang.String label, java.lang.String command)
label
- will be used for the button and thecommand
- will be returned to the listener.public void addChoice(java.lang.String label, char mnenomic)
label
- will be used for the button and themnenomic
- will be used for mnemonic characterpublic void addChoice(java.lang.String label)
public void ask(java.lang.String message)
public void askOkay(java.lang.String message)
public void askYesNo(java.lang.String message)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |