edu.hws.jcm.awt
Class MessagePopup

java.lang.Object
  |
  +--edu.hws.jcm.awt.MessagePopup
All Implemented Interfaces:
java.awt.event.ActionListener, ErrorReporter, java.util.EventListener

public class MessagePopup
extends java.lang.Object
implements java.awt.event.ActionListener, ErrorReporter

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
MessagePopup(java.awt.Component source)
          Create a MessagePopup with the give source component.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
          Respond when user clicks OK.
 void clearErrorMessage()
          Clear the error message and close the window.
 java.lang.String getErrorMessage()
          Get the currently displayed error message.
 void setErrorMessage(Controller c, java.lang.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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessagePopup

public MessagePopup(java.awt.Component source)
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 Detail

setErrorMessage

public void setErrorMessage(Controller c,
                            java.lang.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.
Specified by:
setErrorMessage in interface ErrorReporter
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

public java.lang.String getErrorMessage()
Get the currently displayed error message. The return value is null if no error message is being displayed.
Specified by:
getErrorMessage in interface ErrorReporter

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 interface ErrorReporter

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
Respond when user clicks OK. This is not meant to be called directly.
Specified by:
actionPerformed in interface java.awt.event.ActionListener