|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.bibalex.daf.commongui.MessageBox
public class 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.
Field Summary | |
---|---|
private java.awt.Panel |
buttonPanel
|
private java.lang.String |
closeWindowCommand
|
private java.awt.Dialog |
dialog
|
private java.awt.event.ActionEvent |
event
|
private java.awt.Frame |
frame
|
private boolean |
frameNotProvided
|
private java.awt.Canvas |
imageCanvas
|
private java.awt.event.ActionListener |
listener
|
private static int |
MAX_CHARS_PER_LINE
|
private java.lang.String |
title
|
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 |
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,
java.lang.String command)
The @param label will be used for the button and the |
private void |
addMultilineString(java.lang.String message,
java.awt.Container container)
|
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 |
askOkCancel(java.lang.String message)
Same as ask(String message) except adds "Ok" and "Cancel" buttons. |
void |
askYesNo(java.lang.String message)
Same as ask(String message) except adds "Yes" and "No" buttons. |
void |
askYesNoCancel(java.lang.String message)
Same as ask(String message) except adds "Yes", "No" and "Cancel" buttons. |
void |
askYesNoRetry(java.lang.String message)
Same as ask(String message) except adds "Yes", "No" and "Retry" buttons. |
private java.awt.Panel |
createMultiLinePanel(java.lang.String message)
|
private void |
enforceMinimumSize(java.awt.Component comp,
int minWidth,
int minHeight)
|
private void |
fireCloseRequested()
|
private java.awt.GridBagConstraints |
getDefaultConstraints()
|
java.lang.String |
getResult()
Retrieves the result of the message box. |
void |
keyPressed(java.awt.event.KeyEvent evt)
Detects the Escape character and fires the Close request. |
void |
keyReleased(java.awt.event.KeyEvent evt)
Empty Implementation |
void |
keyTyped(java.awt.event.KeyEvent evt)
Empty Implementation |
void |
reportError(java.lang.String message)
Same as ask(String message) except adds an "Okay" button, and an error Image. |
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(java.awt.Frame frame)
If a Frame is provided then it is used to instantiate the modal Dialog. |
void |
setTitle(java.lang.String title)
Sets the Title of the Message Box with the given String . |
static void |
showError(java.lang.String errorMessage,
boolean addDetails)
Shows an error message to the user. |
static void |
showMessage(java.lang.String message)
Shows a normal message to the user. |
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)
Empty Implementation |
void |
windowClosed(java.awt.event.WindowEvent evt)
Empty Implementation |
void |
windowClosing(java.awt.event.WindowEvent evt)
|
void |
windowDeactivated(java.awt.event.WindowEvent evt)
Empty Implementation |
void |
windowDeiconified(java.awt.event.WindowEvent evt)
Empty Implementation |
void |
windowIconified(java.awt.event.WindowEvent evt)
Empty Implementation |
void |
windowOpened(java.awt.event.WindowEvent evt)
Empty Implementation |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.awt.event.ActionListener listener
private java.awt.Dialog dialog
private java.lang.String closeWindowCommand
private java.lang.String title
private java.awt.Frame frame
private boolean frameNotProvided
private java.awt.Panel buttonPanel
private java.awt.Canvas imageCanvas
private java.awt.event.ActionEvent event
private static final int MAX_CHARS_PER_LINE
Constructor Detail |
---|
public MessageBox(java.awt.event.ActionListener listener)
listener
- that will be notified when a button is clicked.
The listener must implement ActionListener.public MessageBox()
Method Detail |
---|
public static void showError(java.lang.String errorMessage, boolean addDetails)
errorMessage
- The message to be displayed to the user.addDetails
- Whether to added details from the log file or not.public static void showMessage(java.lang.String message)
message
- The message to be displayed to the user.public void run()
public void actionPerformed(java.awt.event.ActionEvent evt)
actionPerformed
in interface java.awt.event.ActionListener
ActionListener.actionPerformed(java.awt.event.ActionEvent)
public void windowClosing(java.awt.event.WindowEvent evt)
windowClosing
in interface java.awt.event.WindowListener
WindowListener.windowClosing(java.awt.event.WindowEvent)
public void windowClosed(java.awt.event.WindowEvent evt)
windowClosed
in interface java.awt.event.WindowListener
WindowListener.windowClosed(java.awt.event.WindowEvent)
public void windowDeiconified(java.awt.event.WindowEvent evt)
windowDeiconified
in interface java.awt.event.WindowListener
WindowListener.windowDeiconified(java.awt.event.WindowEvent)
public void windowIconified(java.awt.event.WindowEvent evt)
windowIconified
in interface java.awt.event.WindowListener
WindowListener.windowIconified(java.awt.event.WindowEvent)
public void windowOpened(java.awt.event.WindowEvent evt)
windowOpened
in interface java.awt.event.WindowListener
WindowListener.windowOpened(java.awt.event.WindowEvent)
public void windowActivated(java.awt.event.WindowEvent evt)
windowActivated
in interface java.awt.event.WindowListener
WindowListener.windowActivated(java.awt.event.WindowEvent)
public void windowDeactivated(java.awt.event.WindowEvent evt)
windowDeactivated
in interface java.awt.event.WindowListener
WindowListener.windowDeactivated(java.awt.event.WindowEvent)
public void keyTyped(java.awt.event.KeyEvent evt)
keyTyped
in interface java.awt.event.KeyListener
KeyListener.keyTyped(java.awt.event.KeyEvent)
public void keyPressed(java.awt.event.KeyEvent evt)
keyPressed
in interface java.awt.event.KeyListener
KeyListener.keyPressed(java.awt.event.KeyEvent)
public void keyReleased(java.awt.event.KeyEvent evt)
keyReleased
in interface java.awt.event.KeyListener
KeyListener.keyReleased(java.awt.event.KeyEvent)
private void fireCloseRequested()
public void setActionListener(java.awt.event.ActionListener listener)
listener
- The ActionListener
to be notified.public void setTitle(java.lang.String title)
String
.
title
- The String
to be used as the title.public void setFrame(java.awt.Frame frame)
frame
- The Frame used to use in the Modal Dialog mode.public java.lang.String getResult()
public void setCloseWindowCommand(java.lang.String command)
command
- A String
representing the Command to use upon close.public void useImageCanvas(java.awt.Canvas imageCanvas)
imageCanvas
- The Canvas
to use.public void useImageCanvas(java.lang.String fileName)
fileName
- The path of the Image to load.public void addChoice(java.lang.String label, java.lang.String command)
label
- The label to add on the Button.command
- will be returned to the listener.public void addChoice(java.lang.String label)
label
- The label of the new Choice (Button).public void ask(java.lang.String message)
message
- A String
representing the message to be asked.public void askOkay(java.lang.String message)
message
- A String
representing the message to be asked.public void reportError(java.lang.String message)
message
- A String
representing the message to be asked.public void askYesNo(java.lang.String message)
message
- A String
representing the message to be asked.public void askYesNoCancel(java.lang.String message)
message
- A String
representing the message to be asked.public void askYesNoRetry(java.lang.String message)
message
- A String
representing the message to be asked.public void askOkCancel(java.lang.String message)
message
- A String
representing the message to be asked.private java.awt.Panel createMultiLinePanel(java.lang.String message)
private void addMultilineString(java.lang.String message, java.awt.Container container)
private java.awt.GridBagConstraints getDefaultConstraints()
private void enforceMinimumSize(java.awt.Component comp, int minWidth, int minHeight)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |