org.moyoman.client.reference.util
Class ApplicationSupport

java.lang.Object
  |
  +--org.moyoman.client.reference.util.ApplicationSupport
All Implemented Interfaces:
IGUIConstants

public final class ApplicationSupport
extends Object
implements IGUIConstants

Provides support for Swing applications. This class acts as a facade to commonly needed functionality, typically implemented elsewhere.

If the application is using a tool bar, then the application main panel should be put in the center of the tool bar panel. For example,

getContentPane().add( ApplicationSupport.getToolBarPanel(), BorderLayout.CENTER );
getContentPane().add( ApplicationSupport.createStatusBar( new int[] { 100, 50, 25 } ), BorderLayout.SOUTH );
getToolBarPanel().add( mainPanel, BorderLayout.CENTER );

Hierarchy:
JFrame > ContentPane > ( ToolBarPanel:CENTER > ( JToolBar:NORTH MainPanel:CENTER ) ) StatusBar:SOUTH

Since:
v0.01
Version:
v0.13
Author:
Jeffrey M. Thompson

Field Summary
private static ActionManager _actionManager
          The action manager.
private static Locale _locale
          The locale.
private static Object _owner
          The owner.
private static Cursor _previousCursor
          Handle to the previous cursor.
private static StatusBar _statusBar
          The status bar.
private static JToolBar _toolBar
          The tool bar.
private static JPanel _toolBarPanel
          The panel which holds the tool bar.
private static String PREFERRED_LOCALE_KEY
          The base name of the resource bundle.
private static int STATUS_AREA
          Constant index for the status area.
 
Fields inherited from interface org.moyoman.client.reference.util.IGUIConstants
DEBUG, DIRTY_PROPERTY, GAP, MARGIN, TRANSPARENT_COLOR
 
Constructor Summary
private ApplicationSupport()
          Private constructor to disallow direct instantiation.
 
Method Summary
static JMenu addMenu(JFrame f, String titleKey, String[] itemKeys)
           
static StatusBar createStatusBar(int[] relativeSizes)
          Create the status bar with the given cells.
static JToolBar createToolBar()
          Create the tool bar.
static String formatMessage(String patternKey, String[] params)
          Return a formatted message made up of the resource obtained from the pattern key and the parameters.
static Action getAboutAction()
          Return the about action.
static KeyStroke getAccelerator(int keyCode)
          Return the accelerator for the given key code.
static ActionManager getActionManager()
          Return the action manager, creating it if necessary.
static Color getColor(String key)
          Return the color specified by the given key.
static Action getCopyAction()
          Return the copy action.
static Action getCutAction()
          Return the cut action.
static Action getDeleteAction()
          Return the delete action.
static int getExitConfirmation(JFrame frame)
          Show a dialog requesting confirmation of the exit action.
static Font getFont(String key)
          Return the font specified by the given key.
static Action getHelpAction()
          Return the help action.
static Icon getIcon(String key)
          Return the icon specified by the given key.
static int getInt(String key)
          Return the integer specified by the given key.
static Locale getLocale()
          Return the locale.
static Action getNewAction()
          Return the new action.
static Action getOpenAction()
          Return the open action.
static Action getPasteAction()
          Return the paste action.
static Action getPreferencesAction()
          Return the preferences action.
static Action getQuitAction()
          Return the quit action.
static String getResource(String key)
          Return the resource for the given key.
static Action getSaveAction()
          Return the save action.
static Action getSaveAsAction()
          Return the save as action.
static StatusBar getStatusBar()
          Return the status bar.
static JToolBar getToolBar()
          Return the tool bar.
static JPanel getToolBarPanel()
          Return the tool bar.
static void launch(JFrame f, String title, int x, int y, int w, int h)
          Launch the application in the given frame with the given title with the given bounds.
static void quitActionPerformed(JFrame frame)
          Perform the quit action.
static void setCursorBusy(JFrame frame, boolean busy)
          Set the cursor to busy depending upon the given state.
static void setOwner(Object owner)
          Set the owner object.
static void showStatus(int area, String s)
          Show the given string in the status area of the status bar.
static void showStatus(int area, String s, int displayTime)
          Show the given string in the status area of the status bar.
static void showStatus(String s)
          Show the given string in the status area of the status bar.
static void showStatus(String s, int displayTime)
          Show the given string in the status area of the status bar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATUS_AREA

private static final int STATUS_AREA
Constant index for the status area.

See Also:
Constant Field Values

_previousCursor

private static Cursor _previousCursor
Handle to the previous cursor.


PREFERRED_LOCALE_KEY

private static final String PREFERRED_LOCALE_KEY
The base name of the resource bundle.

See Also:
Constant Field Values

_statusBar

private static StatusBar _statusBar
The status bar.


_toolBar

private static JToolBar _toolBar
The tool bar.


_toolBarPanel

private static JPanel _toolBarPanel
The panel which holds the tool bar. This is needed so the tool bar can be repositioned.


_locale

private static Locale _locale
The locale.


_owner

private static Object _owner
The owner.


_actionManager

private static ActionManager _actionManager
The action manager.

Constructor Detail

ApplicationSupport

private ApplicationSupport()
Private constructor to disallow direct instantiation.

Since:
v0.01
Method Detail

getAboutAction

public static Action getAboutAction()
Return the about action.

Since:
v0.01

getAccelerator

public static KeyStroke getAccelerator(int keyCode)
Return the accelerator for the given key code.

Since:
v0.01

getActionManager

public static ActionManager getActionManager()
Return the action manager, creating it if necessary.

Since:
v0.01

getColor

public static Color getColor(String key)
Return the color specified by the given key.

Parameters:
key - Key which identifies the desired resource.
Since:
v0.01

getCopyAction

public static Action getCopyAction()
Return the copy action.

Since:
v0.01

setCursorBusy

public static void setCursorBusy(JFrame frame,
                                 boolean busy)
Set the cursor to busy depending upon the given state.

Since:
v0.01

getCutAction

public static Action getCutAction()
Return the cut action.

Since:
v0.01

getDeleteAction

public static Action getDeleteAction()
Return the delete action.

Since:
v0.01

getExitConfirmation

public static int getExitConfirmation(JFrame frame)
Show a dialog requesting confirmation of the exit action.

Returns:
JOptionPane.YES_OPTION or JOptionPane.NO_OPTION
Since:
v0.01

getFont

public static Font getFont(String key)
Return the font specified by the given key.

Parameters:
key - Key which identifies the desired resource.
Since:
v0.01

getHelpAction

public static Action getHelpAction()
Return the help action.

Since:
v0.01

getIcon

public static Icon getIcon(String key)
Return the icon specified by the given key.

Since:
v0.01

getInt

public static int getInt(String key)
Return the integer specified by the given key.

Parameters:
key - Key which identifies the desired resource.
Since:
v0.13

getLocale

public static Locale getLocale()
Return the locale.

Since:
v0.01

getNewAction

public static Action getNewAction()
Return the new action.

Since:
v0.01

getOpenAction

public static Action getOpenAction()
Return the open action.

Since:
v0.01

setOwner

public static void setOwner(Object owner)
Set the owner object. This object is the target of ActionManager actions.

Since:
v0.01

getPasteAction

public static Action getPasteAction()
Return the paste action.

Since:
v0.01

getPreferencesAction

public static Action getPreferencesAction()
Return the preferences action.

Since:
v0.01

getQuitAction

public static Action getQuitAction()
Return the quit action.

Since:
v0.01

getResource

public static String getResource(String key)
Return the resource for the given key.

Since:
v0.01

getSaveAction

public static Action getSaveAction()
Return the save action.

Since:
v0.01

getSaveAsAction

public static Action getSaveAsAction()
Return the save as action.

Since:
v0.01

getStatusBar

public static StatusBar getStatusBar()
Return the status bar.

Throws:
IllegalStateException - if the status bar has not yet been created.
Since:
v0.01

getToolBar

public static JToolBar getToolBar()
Return the tool bar.

Since:
v0.01

getToolBarPanel

public static JPanel getToolBarPanel()
Return the tool bar.

Since:
v0.01

addMenu

public static JMenu addMenu(JFrame f,
                            String titleKey,
                            String[] itemKeys)
Since:
v0.01

createStatusBar

public static StatusBar createStatusBar(int[] relativeSizes)
Create the status bar with the given cells.

Since:
v0.01

createToolBar

public static JToolBar createToolBar()
Create the tool bar.


formatMessage

public static String formatMessage(String patternKey,
                                   String[] params)
Return a formatted message made up of the resource obtained from the pattern key and the parameters.

Since:
v0.01

launch

public static void launch(JFrame f,
                          String title,
                          int x,
                          int y,
                          int w,
                          int h)
Launch the application in the given frame with the given title with the given bounds.

Since:
v0.01

quitActionPerformed

public static void quitActionPerformed(JFrame frame)
Perform the quit action.

Since:
v0.01

showStatus

public static void showStatus(int area,
                              String s)
Show the given string in the status area of the status bar.

Since:
v0.01

showStatus

public static void showStatus(int area,
                              String s,
                              int displayTime)
Show the given string in the status area of the status bar.

Since:
v0.01

showStatus

public static void showStatus(String s)
Show the given string in the status area of the status bar.

Since:
v0.01

showStatus

public static void showStatus(String s,
                              int displayTime)
Show the given string in the status area of the status bar.

Since:
v0.01