ccs.utils
Class MsgBox

java.lang.Object
  extended by ccs.utils.MsgBox

public class MsgBox
extends java.lang.Object

A general-purpose message box. The idea was to come up with something similar to (and maybe a little better than) the win32 MessageBox function. Before swing, we did this ourselves; now, MsgBox is a simplifying wrapper around FormDialog, which is in turn a wrapper around JOptionPane.

As a workaround to a bug in Swing 1.0.1, the window title of the box is invariant across all message boxes seen in the app. The app title is the best candidate for this title. The title of the message itself (which is not invariant) is displayed as a line of larger text inside the window. This may no longer be needed - we haven't checked recently.


Field Summary
static int ARGH
           
static java.lang.String boxtitle
          The Window title.
static int CANCEL
          User selected cancel.
static int INFO
          A message for your information.
static int LOSE
          A minor problem
static int NO
          User selected No.
static int NOALL
          User selected No to All.
static int YES
          User selected Yes.
static int YESALL
          User selected Yes to All.
 
Constructor Summary
MsgBox()
           
 
Method Summary
static boolean confirm(java.awt.Component parent, java.lang.String title, java.lang.Object msg)
          Display an OK / Cancel confirmation dialog.
static javax.swing.JComponent flushRight(javax.swing.JComponent c)
          Right-align the supplied component within a panel, and return the panel.
static void msg(java.awt.Component parent, java.lang.String title, java.lang.Object msg, int type)
          Display a multiline message box.
static int multiconfirm(java.awt.Component parent, java.lang.String title, java.lang.Object msg)
          Display a Yes / No / Cancel confirmation dialog.
static int quinConfirm(java.awt.Component parent, java.lang.String title, java.lang.Object msg)
           
static void setBoxTitle(java.lang.String s)
          Set the window title for all JOptionPane users within the app.
static boolean ynconfirm(java.awt.Component parent, java.lang.String title, java.lang.Object msg)
          Display a Yes / No confirmation dialog.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

boxtitle

public static java.lang.String boxtitle
The Window title. Invariant across all users of JOptionPane within the app. Can be an I18N key.


INFO

public static final int INFO
A message for your information. Not an error.

See Also:
Constant Field Values

LOSE

public static final int LOSE
A minor problem

See Also:
Constant Field Values

ARGH

public static final int ARGH
See Also:
Constant Field Values

CANCEL

public static final int CANCEL
User selected cancel.

See Also:
Constant Field Values

YES

public static final int YES
User selected Yes.

See Also:
Constant Field Values

NO

public static final int NO
User selected No.

See Also:
Constant Field Values

YESALL

public static final int YESALL
User selected Yes to All.

See Also:
Constant Field Values

NOALL

public static final int NOALL
User selected No to All.

See Also:
Constant Field Values
Constructor Detail

MsgBox

public MsgBox()
Method Detail

setBoxTitle

public static void setBoxTitle(java.lang.String s)
Set the window title for all JOptionPane users within the app. This includes MsgBox, (Sense)StringDialog, PasswordDialog and any others you define. The argument should be an I18N key; often it's a good idea to have this key translate to the title of the app.

Parameters:
s - The window title.

msg

public static void msg(java.awt.Component parent,
                       java.lang.String title,
                       java.lang.Object msg,
                       int type)
Display a multiline message box. The title shown here is displayed inside the box in a larger font.

Parameters:
parent - The parent Component. May be null.
title - the "title" of the dialog.
msg - the detail message, anything that JOptionPane can relate to.
type - the type (severity) of the incident.

confirm

public static boolean confirm(java.awt.Component parent,
                              java.lang.String title,
                              java.lang.Object msg)
Display an OK / Cancel confirmation dialog.

Parameters:
parent - The parent Component. May be null.
title - the "title" of the dialog.
msg - The detail message - anything JOptionPane can render.
Returns:
True for OK, false for cancel.

ynconfirm

public static boolean ynconfirm(java.awt.Component parent,
                                java.lang.String title,
                                java.lang.Object msg)
Display a Yes / No confirmation dialog.

Parameters:
parent - The parent Component. May be null.
title - the "title" of the dialog.
msg - The detail message - anything JOptionPane can render.
Returns:
True for Yes, false for cancel.

multiconfirm

public static int multiconfirm(java.awt.Component parent,
                               java.lang.String title,
                               java.lang.Object msg)
Display a Yes / No / Cancel confirmation dialog.

Parameters:
parent - The parent Component. May be null.
title - the "title" of the dialog.
msg - the detail message - anything a JOptionPane can render.
Returns:
One of the constants YES, NO or CANCEL defined in this class.

quinConfirm

public static int quinConfirm(java.awt.Component parent,
                              java.lang.String title,
                              java.lang.Object msg)

flushRight

public static javax.swing.JComponent flushRight(javax.swing.JComponent c)
Right-align the supplied component within a panel, and return the panel. Useful for things like "Choose..." buttons within MsgBox payloads - without this, the button is full-width, and looks a bit silly.

Parameters:
c - The component to right-align.
Returns:
A suitable component to add to the payload.