Package edu.hws.jcm.awt
Class MessagePopup
java.lang.Object
edu.hws.jcm.awt.MessagePopup
- All Implemented Interfaces:
ErrorReporter
,ActionListener
,EventListener
The class MessagePopup represents a Window that pops up to display an error
message. A MessagePopup object is created by a "source" component. If
that component is contained in a Frame, then the popup will be a modal dialog
box with that Parent. If the component is not in a Frame (or is null), then an
independent Frame is used. The message box is popped up when reportError() is
called. It is closed either when the user clicks the OK button,
or if clearErrorMessage() is called.
-
Constructor Summary
ConstructorsConstructorDescriptionMessagePopup
(Component source) Create a MessagePopup with the give source component. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Respond when user clicks OK.void
Clear the error message and close the window.Get the currently displayed error message.void
setErrorMessage
(Controller c, String message) Show the given message in a dialog box or independent window, depending on whether the source component is contained in a Frame or not.
-
Constructor Details
-
MessagePopup
Create a MessagePopup with the give source component. If source is null, then an independent window will always be used to show the error message.
-
-
Method Details
-
setErrorMessage
Show the given message in a dialog box or independent window, depending on whether the source component is contained in a Frame or not.- Specified by:
setErrorMessage
in interfaceErrorReporter
- Parameters:
c
- The Controller that calls this method, or null if it is not called by a Controller. (The Controller, if any, will be notified when the error message is cleared.)message
- The message to display.
-
getErrorMessage
Get the currently displayed error message. The return value is null if no error message is being displayed.- Specified by:
getErrorMessage
in interfaceErrorReporter
-
clearErrorMessage
public void clearErrorMessage()Clear the error message and close the window. This can be called from outside this class. It is called automatically when the user clicks the OK button or close box of the window that displays the error message.- Specified by:
clearErrorMessage
in interfaceErrorReporter
-
actionPerformed
Respond when user clicks OK. This is not meant to be called directly.- Specified by:
actionPerformed
in interfaceActionListener
-