org.vizzini.ui
Class ApplicationSupport

java.lang.Object
  extended by org.vizzini.ui.ApplicationSupport

public final class ApplicationSupport
extends Object

Provides support for Swing applications. 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.1
Version:
v0.3
Author:
Jeffrey M. Thompson, David Geary

Method Summary
static JMenu addMenu(Container container, String titleKey, int mnemonic, String[] itemKeys)
          Add a new menu with menu items for the given strings.
static JMenu addMenu(JApplet a, String titleKey, int mnemonic, String[] itemKeys)
          Add a new menu with menu items for the given strings.
static JMenu addMenu(JFrame f, String titleKey, int mnemonic, String[] itemKeys)
          Add a new menu with menu items for the given strings.
protected static JMenu addMenuHelper(JMenuBar mb, String titleKey, String[] itemKeys)
          Add a new menu with menu items for the given strings.
protected static void addMenuTo(Container container, JMenu menu)
          Return the requested menu, creating it and adding it to the menu bar if neccessary.
protected static void clear()
          Clear.
static JLabel createLabel(String key)
          Create a properly formatted label for use with an edit field.
static StatusBar createStatusBar(int[] relativeSizes)
          Create the status bar with the given cells.
static JToolBar createToolBar()
          Create the tool bar.
static String formatLabelString(String key)
          Create a properly formatted label for use with an edit field.
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 AudioClip getAudioClip(String key)
          Return the audio clip specified by the given key.
static boolean getBoolean(String key)
          Return the boolean specified by the given key.
static boolean getBoolean(String key, boolean defaultValue)
          Return the boolean specified by the given key, or the given default value if the key is not found.
static Class getClass(String key)
          Return the Class specified by the given key.
static Color getColor(String key)
          Return the color specified by the given key.
static Color getColor(String key, Color defaultColor)
          Return the color specified by the given key.
static Color getColorPreference(String key)
          Return the color specified by the given key in the preferences bundle.
static String getConfigBundleName()
          Return the configuration bundle name.
static JMenu getEditMenu(Container container)
          Return the edit menu.
static JMenu getEditMenuDefault(Container container)
          Return the default edit menu.
static int getExitConfirmation(JFrame frame)
          Show a dialog requesting confirmation of the exit action.
static JMenu getFileMenu(Container container)
          Return the file menu.
static JMenu getFileMenuDefault(Container container)
          Return the default file menu.
static Font getFont(String key)
          Return the font specified by the given key.
static Font getFontPreference(String key)
          Return the font specified by the given key in the preferences bundle.
static JMenu getHelpMenu(Container container)
          Return the help menu.
static JMenu getHelpMenuDefault(Container container)
          Return the default help menu.
static Icon getIcon(String key)
          Return the icon specified by the given key.
static int getInt(String key)
          Return the int specified by the given key.
static int getInt(String key, int defaultValue)
          Return the int specified by the given key, or the given default value if the key is not found.
static Locale getLocale()
          Return the locale.
static JMenuBar getMenuBar(JApplet a)
          Return the menu bar from the given frame, creating it if necessary.
static JMenuBar getMenuBar(JFrame f)
          Return the menu bar from the given frame, creating it if necessary.
protected static JMenu getMenuFor(Container container, String actionName, String[] itemKeys)
          Return the requested menu, creating it and adding it to the menu bar if neccessary.
static JMenu getMenuNamed(JMenuBar menuBar, String menuName)
          Return the menu with the given name.
static JMenu getOptionsMenu(Container container)
          Return the options menu.
static String getPreference(String key)
          Return the preference for the given key.
static String getResource(String key)
          Return the resource for the given key.
static String getResource(String key, Object[] args)
          Return the resource for the given key using the given message arguments.
static String getResource(String key, String defaultValue)
          Return the resource for the given key.
static StatusBar getStatusBar()
          Return the status bar.
static String getStringBundleName()
          Return the string bundle name.
static JToolBar getToolBar()
          Return the tool bar.
static JPanel getToolBarPanel()
          Return the tool bar.
static JMenu getViewMenu(Container container)
          Return the view menu.
static JMenu getViewMenuDefault(Container container)
          Return the default view menu.
static void launch(JFrame f, String title, Image image, 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 openURL(AbstractApp app, String urlString)
          Show the given URL in the default browser.
static void openURL(AbstractApp app, URL url)
          Show the given URL in the default browser.
protected static void openURLFromApplet(JApplet applet, URL url)
          Show the given URL in the applet's browser.
static void quitActionPerformed(JFrame frame)
          Perform the quit action.
static void setConfigBundleName(String bundleName)
          Set the configuration bundle name.
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 setStringBundleName(String bundleName)
          Set the string bundle name.
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
 

Method Detail

addMenu

public static JMenu addMenu(Container container,
                            String titleKey,
                            int mnemonic,
                            String[] itemKeys)
Add a new menu with menu items for the given strings.

Since:
v0.1

addMenu

public static JMenu addMenu(JFrame f,
                            String titleKey,
                            int mnemonic,
                            String[] itemKeys)
Add a new menu with menu items for the given strings.

Since:
v0.1

addMenu

public static JMenu addMenu(JApplet a,
                            String titleKey,
                            int mnemonic,
                            String[] itemKeys)
Add a new menu with menu items for the given strings.

Since:
v0.1

createLabel

public static JLabel createLabel(String key)
Create a properly formatted label for use with an edit field.

Since:
v0.1

createStatusBar

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

Since:
v0.1

createToolBar

public static JToolBar createToolBar()
Create the tool bar.


formatLabelString

public static String formatLabelString(String key)
Create a properly formatted label for use with an edit field.

Since:
v0.1

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.1

getAudioClip

public static AudioClip getAudioClip(String key)
Return the audio clip specified by the given key.

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

getBoolean

public static boolean getBoolean(String key)
Return the boolean specified by the given key.

Since:
v0.1

getBoolean

public static boolean getBoolean(String key,
                                 boolean defaultValue)
Return the boolean specified by the given key, or the given default value if the key is not found.

Since:
v0.1

getClass

public static Class getClass(String key)
Return the Class specified by the given key.

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

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.1

getColor

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

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

getColorPreference

public static Color getColorPreference(String key)
Return the color specified by the given key in the preferences bundle.

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

getConfigBundleName

public static String getConfigBundleName()
Return the configuration bundle name.

Since:
v0.1

getEditMenu

public static JMenu getEditMenu(Container container)
Return the edit menu.

Since:
v0.1

getEditMenuDefault

public static JMenu getEditMenuDefault(Container container)
Return the default edit menu.

Since:
v0.1

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.1

getFileMenu

public static JMenu getFileMenu(Container container)
Return the file menu.

Since:
v0.1

getFileMenuDefault

public static JMenu getFileMenuDefault(Container container)
Return the default file menu.

Since:
v0.1

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.1

getFontPreference

public static Font getFontPreference(String key)
Return the font specified by the given key in the preferences bundle.

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

getHelpMenu

public static JMenu getHelpMenu(Container container)
Return the help menu.

Since:
v0.1

getHelpMenuDefault

public static JMenu getHelpMenuDefault(Container container)
Return the default help menu.

Since:
v0.1

getIcon

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

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

getInt

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

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

getInt

public static int getInt(String key,
                         int defaultValue)
Return the int specified by the given key, or the given default value if the key is not found.

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

getLocale

public static Locale getLocale()
Return the locale.

Since:
v0.1

getMenuBar

public static JMenuBar getMenuBar(JApplet a)
Return the menu bar from the given frame, creating it if necessary.

Since:
v0.1

getMenuBar

public static JMenuBar getMenuBar(JFrame f)
Return the menu bar from the given frame, creating it if necessary.

Since:
v0.1

getMenuNamed

public static JMenu getMenuNamed(JMenuBar menuBar,
                                 String menuName)
Return the menu with the given name.

Parameters:
menuBar - The menu bar to search.
menuName - The (possibly localized) name of the menu to find.
Since:
v0.1

getOptionsMenu

public static JMenu getOptionsMenu(Container container)
Return the options menu.

Since:
v0.1

getPreference

public static String getPreference(String key)
Return the preference for the given key.

Since:
v0.1

getResource

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

Since:
v0.1

getResource

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

Since:
v0.1

getResource

public static String getResource(String key,
                                 Object[] args)
Return the resource for the given key using the given message arguments. In the resource value, specify arguments as {0}, {1}, etc. These are then replaced with the values args[0], args[1], etc. More detailed formatted is also possible; see the Java Tutorial.

Parameters:
key - Message key.
args - Message arguments.
Since:
v0.2

getStatusBar

public static StatusBar getStatusBar()
Return the status bar.

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

getStringBundleName

public static String getStringBundleName()
Return the string bundle name.

Since:
v0.1

getToolBar

public static JToolBar getToolBar()
Return the tool bar.

Since:
v0.1

getToolBarPanel

public static JPanel getToolBarPanel()
Return the tool bar.

Since:
v0.1

getViewMenu

public static JMenu getViewMenu(Container container)
Return the view menu.

Since:
v0.1

getViewMenuDefault

public static JMenu getViewMenuDefault(Container container)
Return the default view menu.

Since:
v0.1

launch

public static void launch(JFrame f,
                          String title,
                          Image image,
                          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.1

openURL

public static void openURL(AbstractApp app,
                           URL url)
                    throws IOException
Show the given URL in the default browser.

Throws:
IOException
Since:
v0.1

openURL

public static void openURL(AbstractApp app,
                           String urlString)
                    throws IOException
Show the given URL in the default browser.

Throws:
IOException
Since:
v0.1

quitActionPerformed

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

Since:
v0.1

setConfigBundleName

public static void setConfigBundleName(String bundleName)
Set the configuration bundle name.

Since:
v0.1

setCursorBusy

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

Since:
v0.1

setOwner

public static void setOwner(Object owner)
Set the owner object. This object is the target of ActionManager actions. This object's package defines the path for resource items.

Since:
v0.1

setStringBundleName

public static void setStringBundleName(String bundleName)
Set the string bundle name.

Since:
v0.1

showStatus

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

Since:
v0.1

showStatus

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

Since:
v0.1

showStatus

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

Since:
v0.1

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.1

addMenuHelper

protected static JMenu addMenuHelper(JMenuBar mb,
                                     String titleKey,
                                     String[] itemKeys)
Add a new menu with menu items for the given strings.

Since:
v0.1

addMenuTo

protected static void addMenuTo(Container container,
                                JMenu menu)
Return the requested menu, creating it and adding it to the menu bar if neccessary.


clear

protected static void clear()
Clear.

Since:
v0.1

getMenuFor

protected static JMenu getMenuFor(Container container,
                                  String actionName,
                                  String[] itemKeys)
Return the requested menu, creating it and adding it to the menu bar if neccessary.


openURLFromApplet

protected static void openURLFromApplet(JApplet applet,
                                        URL url)
                                 throws IOException
Show the given URL in the applet's browser.

Throws:
IOException
Since:
v0.1


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02