jsky.util.gui
Class DialogUtil

java.lang.Object
  extended by jsky.util.gui.DialogUtil

public class DialogUtil
extends java.lang.Object

Utility class with static methods for commonly used dialogs.


Constructor Summary
DialogUtil()
           
 
Method Summary
static void addExceptionHandler(ExceptionHandler handler)
          Add an exception handler, to be called whenever DialogUtil.error(Exception) is called.
static int confirm(java.awt.Component parentComponent, java.lang.String msg)
          Display a confirm dialog with YES, NO, CANCEL buttons and return a JOptionPane constant indicating the choice.
static int confirm(java.lang.String msg)
          Display a confirm dialog with YES, NO, CANCEL buttons and return a JOptionPane constant indicating the choice.
static void error(java.awt.Component parentComponent, java.lang.Exception e)
          Report an error message based on the given exception.
static void error(java.awt.Component parentComponent, java.lang.String msg)
          Report an error message.
static void error(java.lang.Exception e)
          Report an error message based on the given exception.
static void error(java.lang.String msg)
          Report an error message.
static javax.swing.JDesktopPane getDesktop()
          This should be called if you want to use internal dialogs
static java.lang.String input(java.awt.Component parentComponent, java.lang.String msg)
          Get an input string from the user and return it.
static java.lang.Object input(java.awt.Component parentComponent, java.lang.String msg, java.lang.Object[] choices, java.lang.Object initialValue)
          Get a choice from the user and return it.
static java.lang.String input(java.awt.Component parentComponent, java.lang.String msg, java.lang.String initialValue)
          Get an input string from the user and return it.
static java.lang.String input(java.lang.String msg)
          Get an input string from the user and return it.
static void message(java.awt.Component parentComponent, java.lang.String msg)
          Display an informational message.
static void message(java.lang.String msg)
          Display an informational message.
static void removeExceptionHandler(ExceptionHandler handler)
          Remove an exception handler
static void setDesktop(javax.swing.JDesktopPane d)
          This should be called if you want to use internal dialogs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DialogUtil

public DialogUtil()
Method Detail

setDesktop

public static void setDesktop(javax.swing.JDesktopPane d)
This should be called if you want to use internal dialogs


getDesktop

public static javax.swing.JDesktopPane getDesktop()
This should be called if you want to use internal dialogs


addExceptionHandler

public static void addExceptionHandler(ExceptionHandler handler)
Add an exception handler, to be called whenever DialogUtil.error(Exception) is called.


removeExceptionHandler

public static void removeExceptionHandler(ExceptionHandler handler)
Remove an exception handler


error

public static void error(java.awt.Component parentComponent,
                         java.lang.String msg)
Report an error message.

Parameters:
parentComponent - display the dialog over the given component
msg - the error message

error

public static void error(java.lang.String msg)
Report an error message.

Parameters:
msg - the error message

error

public static void error(java.awt.Component parentComponent,
                         java.lang.Exception e)
Report an error message based on the given exception.

Parameters:
parentComponent - display the dialog over the given component
e - the exception containing the error information

error

public static void error(java.lang.Exception e)
Report an error message based on the given exception.

Parameters:
e - the exception containing the error information

message

public static void message(java.awt.Component parentComponent,
                           java.lang.String msg)
Display an informational message.

Parameters:
parentComponent - display the dialog over the given component
msg - the message

message

public static void message(java.lang.String msg)
Display an informational message.

Parameters:
msg - the message

input

public static java.lang.String input(java.awt.Component parentComponent,
                                     java.lang.String msg,
                                     java.lang.String initialValue)
Get an input string from the user and return it.

Parameters:
parentComponent - display the dialog over the given component
msg - the message to display
initialValue - the initial value to display
Returns:
the value typed in by the user, or null if Cancel was pressed

input

public static java.lang.String input(java.awt.Component parentComponent,
                                     java.lang.String msg)
Get an input string from the user and return it.

Parameters:
parentComponent - display the dialog over the given component
msg - the message to display
Returns:
the value typed in by the user, or null if Cancel was pressed

input

public static java.lang.String input(java.lang.String msg)
Get an input string from the user and return it.

Parameters:
msg - the message to display
Returns:
the value typed in by the user, or null if Cancel was pressed

input

public static java.lang.Object input(java.awt.Component parentComponent,
                                     java.lang.String msg,
                                     java.lang.Object[] choices,
                                     java.lang.Object initialValue)
Get a choice from the user and return it.

Parameters:
parentComponent - display the dialog over the given component
msg - the message to display
choices - an array of items to choose from
initialValue - the initial value to display
Returns:
the value chosen by the user, or null if Cancel was pressed

confirm

public static int confirm(java.awt.Component parentComponent,
                          java.lang.String msg)
Display a confirm dialog with YES, NO, CANCEL buttons and return a JOptionPane constant indicating the choice.

Parameters:
parentComponent - display the dialog over the given component
msg - the message to display
Returns:
a JOptionPane constant indicating the choice

confirm

public static int confirm(java.lang.String msg)
Display a confirm dialog with YES, NO, CANCEL buttons and return a JOptionPane constant indicating the choice.

Parameters:
msg - the message to display
Returns:
a JOptionPane constant indicating the choice