qflib 0.98.0

de.qfs.lib.gui
Class Message

java.lang.Object
  |
  +--de.qfs.lib.gui.Message

public abstract class Message
extends java.lang.Object

A collection of convenience methods to bring up localized versions of standard dialogs.

Before any dialogs can be shown, the resources to use must be set with the setResources method. The resource bundle must contain at least the following values:
dialog.cancel.name Default label for the Cancel button
dialog.no.name Default label for the No button
dialog.ok.name Default label for the OK button
dialog.yes.name Default label for the Yes button
These resources are provided as /de/qfs/lib/resources/properties/qflib in qflib.jar and added automatically during initialization of the Message class.

Additionally for each message to display the following resources are used:
<messageName>.title The title for <messageName>
<messageName>.message The message for <messageName>
<messageName>.custom Number of custom objects to display. If this is set, <messageName>.message may be omitted. The custom objects to display are taken from the param array in the call to showMessage. See JOptionPane.
<messageName>.type The message type for <messageName>. Possible values are plain, info, question and error, which is the default.
<messageName>.buttons The buttons to use for <messageName>. Possible values are custom, okcancel, yesno, yesnocancel and ok, which is the default.
<messageName>.button<num> If button type custom was chosen, use one button<num> resource for each button with num starting at 0 in the order in which they are to appear.
<messageName>.icon The icon resource name for <messageName> (optional)

The Dialogs shown will have their name set depending on the type of the message as follows:
JOptionPane.PLAIN_MESSAGE "Message.message"
JOptionPane.INFORMATION_MESSAGE "Message.info"
JOptionPane.QUESTION_MESSAGE "Message.question"
JOptionPane.ERROR_MESSAGE "Message.error"

Version:
$Revision: 1.15 $
Author:
Gregor Schmid
See Also:
JOptionPane

Method Summary
static void addResources(java.util.ResourceBundle resources)
          Add some resources of the Message class.
static java.lang.String format(java.lang.String resource, java.lang.Object[] param)
          Convenience method that creates a message from a resource string and its parameters.
static java.util.ResourceBundle getResources()
          Get the resources of the Message class.
static void setResources(java.util.ResourceBundle resources)
          Set the resources of the Message class.
static int showMessage(java.awt.Component parent, java.lang.String resource)
          Bring up a localized message dialog.
static int showMessage(java.awt.Component parent, java.lang.String resource, java.lang.Object[] param)
          Bring up a parameterized, localized message dialog.
static int showOK(java.awt.Component parent, java.lang.Object message, java.lang.String title, int messageType, javax.swing.Icon icon)
          Bring up a localized confirm dialog with OK as the single option.
static int showOKCancel(java.awt.Component parent, java.lang.Object message, java.lang.String title, int messageType, javax.swing.Icon icon)
          Bring up a localized OK/Cancel dialog.
static int showYesNo(java.awt.Component parent, java.lang.Object message, java.lang.String title, int messageType, javax.swing.Icon icon)
          Bring up a localized Yes/No dialog.
static int showYesNoCancel(java.awt.Component parent, java.lang.Object message, java.lang.String title, int messageType, javax.swing.Icon icon)
          Bring up a localized Yes/No/Cancel dialog.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getResources

public static final java.util.ResourceBundle getResources()
Get the resources of the Message class.
Returns:
The resources.

setResources

public static final void setResources(java.util.ResourceBundle resources)
Set the resources of the Message class.
Parameters:
resources - The resources to set.

addResources

public static final void addResources(java.util.ResourceBundle resources)
Add some resources of the Message class.
Parameters:
resources - The resources to add.

showYesNo

public static int showYesNo(java.awt.Component parent,
                            java.lang.Object message,
                            java.lang.String title,
                            int messageType,
                            javax.swing.Icon icon)
Bring up a localized Yes/No dialog.
Parameters:
parent - A Component belonging to the parent frame for the dialog.
message - The message to display.
title - The title of the dialog.
messageType - The type of the message, see JOptionPane.
icon - An icon for the message.
Returns:
YES_OPTION, NO_OPTION or CLOSED_OPTION if the dialog is closed without selecting an option (values taken from JOptionPane).

showYesNoCancel

public static int showYesNoCancel(java.awt.Component parent,
                                  java.lang.Object message,
                                  java.lang.String title,
                                  int messageType,
                                  javax.swing.Icon icon)
Bring up a localized Yes/No/Cancel dialog.
Parameters:
parent - A Component belonging to the parent frame for the dialog.
message - The message to display.
title - The title of the dialog.
messageType - The type of the message, see JOptionPane.
icon - An icon for the message.
Returns:
YES_OPTION, NO_OPTION, CANCEL_OPTION or CLOSED_OPTION if the dialog is closed without selecting an option (values taken from JOptionPane).

showOKCancel

public static int showOKCancel(java.awt.Component parent,
                               java.lang.Object message,
                               java.lang.String title,
                               int messageType,
                               javax.swing.Icon icon)
Bring up a localized OK/Cancel dialog.
Parameters:
parent - A Component belonging to the parent frame for the dialog.
message - The message to display.
title - The title of the dialog.
messageType - The type of the message, see JOptionPane.
icon - An icon for the message.
Returns:
OK_OPTION, CANCEL_OPTION or CLOSED_OPTION if the dialog is closed without selecting an option (values taken from JOptionPane).

showOK

public static int showOK(java.awt.Component parent,
                         java.lang.Object message,
                         java.lang.String title,
                         int messageType,
                         javax.swing.Icon icon)
Bring up a localized confirm dialog with OK as the single option.
Parameters:
parent - A Component belonging to the parent frame for the dialog.
message - The message to display.
title - The title of the dialog.
messageType - The type of the message, see JOptionPane.
icon - An icon for the message.
Returns:
OK_OPTION or CLOSED_OPTION if the dialog is closed without selecting an option (values taken from JOptionPane).

showMessage

public static int showMessage(java.awt.Component parent,
                              java.lang.String resource)
Bring up a localized message dialog. The message, title, type and icon for the dialog are taken from the resources set through setResources.
Parameters:
parent - A Component belonging to the parent frame for the dialog.
resource - The basename of the resources to use.
Returns:
OK_OPTION or CLOSED_OPTION if the dialog is closed without selecting an option (values taken from JOptionPane).

showMessage

public static int showMessage(java.awt.Component parent,
                              java.lang.String resource,
                              java.lang.Object[] param)
Bring up a parameterized, localized message dialog. The message, title, type and icon for the dialog are taken from the resources set through setResources.
Parameters:
parent - A Component belonging to the parent frame for the dialog.
resource - The basename of the resources to use.
param - Array of parameters for the message. If the resource for custom is set, the first n objects are used as custom objects. The rest is used to format the message.
Returns:
OK_OPTION or CLOSED_OPTION if the dialog is closed without selecting an option (values taken from JOptionPane).

format

public static java.lang.String format(java.lang.String resource,
                                      java.lang.Object[] param)
Convenience method that creates a message from a resource string and its parameters.
Parameters:
resource - The name of the resource.
param - The parameter values.
Returns:
The formatted, localized string.

qflib 0.98.0