com.glaivestone.javax.swing
Class MessageDialog

java.lang.Object
  |
  +--com.glaivestone.javax.swing.MessageDialog

public class MessageDialog
extends java.lang.Object

The MessageDialog class is used to display notification and confirmation messages.

Origins

This class exists primarily to compensate for deficiencies in the underlying Swing JOptionPane dialog. The purpose of a view should be to present its content to the user in a readable fashion, but JOptionPane is regrettably too stupid to compute a proper rendering for text that needs line wrapping or line breaks in order to make its content visible. This should emphatically not be the client's problem - they should be able to expect that the text they give to the dialog is presented reasonably, without having to compute the presentation themselves.

This class was inspired by the Visual Smalltalk MessageBox class, an easy-to-use facility for display user messages.

Author:
Deb Lewis

Field Summary
static java.lang.String DEFAULT_CONFIRMER_TITLE
           
static java.lang.String DEFAULT_ERROR_NOTIFIER_TITLE
           
static java.lang.String DEFAULT_INFORMATION_NOTIFIER_TITLE
           
static java.lang.String DEFAULT_WARNING_NOTIFIER_TITLE
           
static int multiLineMessageThreshold
          The maximum number of characters in a message before switching to a multi-line text component which provides line breaking.
static int RESULT_ACCEPTED
           
static int RESULT_CANCELLED
           
static int RESULT_REJECTED
           
static boolean TRACE_SIZING
           
static boolean USE_WIDTH_HEURISTIC
           
 
Method Summary
static java.lang.Object composeMessageArgument(java.lang.String message)
          Compose the argument to pass to JOptionPane for a message string.
static boolean confirm(java.lang.String message, java.awt.Component client)
          Display a confirmation dialog that prompts the user to confirm or deny a proposition.
static boolean confirm(java.lang.String message, int optionType, java.awt.Component client)
          Display a confirmation dialog that prompts the user to confirm or deny a proposition.
static boolean confirm(java.lang.String title, java.lang.String message, java.awt.Component client)
          Display a confirmation dialog that prompts the user to confirm or deny a proposition.
static boolean confirm(java.lang.String title, java.lang.String message, int optionType, java.awt.Component client)
          Display a confirmation dialog that prompts the user to confirm or deny a proposition.
static int confirmOrCancel(java.lang.String message, java.awt.Component client)
          Display a confirmation dialog that prompts the user to confirm or deny a proposition.
static int confirmOrCancel(java.lang.String title, java.lang.String message, java.awt.Component client)
          Display a confirmation dialog that prompts the user to confirm or deny a proposition.
static void displayError(java.lang.String message, java.awt.Component client)
          Display an error message to the user.
static void displayError(java.lang.String title, java.lang.String message, java.awt.Component client)
          Display an error message to the user.
static void displayMessage(java.lang.String message, java.awt.Component client)
          Display an information message to the user.
static void displayMessage(java.lang.String title, java.lang.String message, java.awt.Component client)
          Display an information message to the user.
static void displayMessage(java.lang.String title, java.lang.String message, int messageType, java.awt.Component client)
          Display a notification message to the user with the given title and message on behalf of a requesting window.
static void displayWarning(java.lang.String message, java.awt.Component client)
          Display a warning message to the user.
static void displayWarning(java.lang.String title, java.lang.String message, java.awt.Component client)
          Display a warning message to the user.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESULT_ACCEPTED

public static final int RESULT_ACCEPTED
See Also:
Constant Field Values

RESULT_REJECTED

public static final int RESULT_REJECTED
See Also:
Constant Field Values

RESULT_CANCELLED

public static final int RESULT_CANCELLED
See Also:
Constant Field Values

DEFAULT_CONFIRMER_TITLE

public static final java.lang.String DEFAULT_CONFIRMER_TITLE
See Also:
Constant Field Values

DEFAULT_INFORMATION_NOTIFIER_TITLE

public static final java.lang.String DEFAULT_INFORMATION_NOTIFIER_TITLE
See Also:
Constant Field Values

DEFAULT_WARNING_NOTIFIER_TITLE

public static final java.lang.String DEFAULT_WARNING_NOTIFIER_TITLE
See Also:
Constant Field Values

DEFAULT_ERROR_NOTIFIER_TITLE

public static final java.lang.String DEFAULT_ERROR_NOTIFIER_TITLE
See Also:
Constant Field Values

multiLineMessageThreshold

public static int multiLineMessageThreshold
The maximum number of characters in a message before switching to a multi-line text component which provides line breaking.


USE_WIDTH_HEURISTIC

public static boolean USE_WIDTH_HEURISTIC

TRACE_SIZING

public static boolean TRACE_SIZING
Method Detail

composeMessageArgument

public static java.lang.Object composeMessageArgument(java.lang.String message)
Compose the argument to pass to JOptionPane for a message string. Message with line breaks or which require line wrapping in order to present long text messages are prepared with a suitably multi-line text component.


confirm

public static boolean confirm(java.lang.String message,
                              java.awt.Component client)
Display a confirmation dialog that prompts the user to confirm or deny a proposition. Answer whether the user agreed.


confirm

public static boolean confirm(java.lang.String message,
                              int optionType,
                              java.awt.Component client)
Display a confirmation dialog that prompts the user to confirm or deny a proposition. Answer whether the user agreed.


confirm

public static boolean confirm(java.lang.String title,
                              java.lang.String message,
                              java.awt.Component client)
Display a confirmation dialog that prompts the user to confirm or deny a proposition. Answer whether the user agreed.


confirm

public static boolean confirm(java.lang.String title,
                              java.lang.String message,
                              int optionType,
                              java.awt.Component client)
Display a confirmation dialog that prompts the user to confirm or deny a proposition. Answer whether the user agreed.


confirmOrCancel

public static int confirmOrCancel(java.lang.String message,
                                  java.awt.Component client)
Display a confirmation dialog that prompts the user to confirm or deny a proposition. Answer a response code indicating whether or not the user reached a decision (RESULT_ACCEPTED or RESULT_REJECTED) or punted (RESULT_CANCELLED ).


confirmOrCancel

public static int confirmOrCancel(java.lang.String title,
                                  java.lang.String message,
                                  java.awt.Component client)
Display a confirmation dialog that prompts the user to confirm or deny a proposition. Answer a response code indicating whether or not the user reached a decision (RESULT_ACCEPTED or RESULT_REJECTED) or punted (RESULT_CANCELLED ).


displayError

public static void displayError(java.lang.String message,
                                java.awt.Component client)
Display an error message to the user.


displayError

public static void displayError(java.lang.String title,
                                java.lang.String message,
                                java.awt.Component client)
Display an error message to the user.


displayMessage

public static void displayMessage(java.lang.String message,
                                  java.awt.Component client)
Display an information message to the user.


displayMessage

public static void displayMessage(java.lang.String title,
                                  java.lang.String message,
                                  java.awt.Component client)
Display an information message to the user.


displayMessage

public static void displayMessage(java.lang.String title,
                                  java.lang.String message,
                                  int messageType,
                                  java.awt.Component client)
Display a notification message to the user with the given title and message on behalf of a requesting window. The message type is a JOptionPane message dialog constant.


displayWarning

public static void displayWarning(java.lang.String message,
                                  java.awt.Component client)
Display a warning message to the user.


displayWarning

public static void displayWarning(java.lang.String title,
                                  java.lang.String message,
                                  java.awt.Component client)
Display a warning message to the user.


GFL 1.1 API