org.jdesktop.swing
Class Application

java.lang.Object
  extended byorg.jdesktop.swing.Application

public class Application
extends Object

Class which represents central state and properties for a single client application which can be either a standalone Java application (typically initiated using Java WebStart) or a set of one or more Java applets which share the same code base. There should only be a single Application instance per client application.

This class also encapsulates any functionality which has variable API between applets and Java WebStart applications so that UI components can reliably talk to a single interface for such services.


Constructor Summary
Application()
           
 
Method Summary
 void addSelectionListener(SelectionListener l)
           
 ActionManager getActionManager()
          Return the action manager for this application.
 ActionMap getActionMap()
          Return the action map associated with this application.
static Application getApp(Component c)
          Convenience method for getting the JDNCapp instance given a component instance.
 Iterator getApplets()
           
 URL getBaseURL()
           
static URL getBaseURL(Object obj)
          Will retrieve the applet base url if this application is running in an applet.
static Icon getIcon(String name, Object obj)
           
static Image getImage(String name, Object obj)
           
static Application getInstance()
          Private constructor so that an Application can't be directly instantated.
static Application getInstance(Object key)
          Factory method for obtaining the Application instance associated with the application designated by the specified key.
 SelectionListener[] getSelectionListeners()
           
 Image getSplashImage()
           
 String getTitle()
           
 Image getTitleBarImage()
           
static URL getURL(String value, Object obj)
          Fetches a url of a resource value using the clasloader and relative path of obj.
static URL getURLResource(String value, Object obj)
           
 String getVersionString()
           
 Iterator getWindows()
           
 boolean isRunningInSandbox()
           
 boolean isStandalone()
          Returns true if running as a standalone application and returns false if running ne or more applets.
 void registerApplet(Applet applet)
           
 void registerWindow(Window window)
          Registers a window with the application instance.
 void removeSelectionListener(SelectionListener l)
           
 void setBaseURL(URL baseURL)
          Sets the "baseURL" property of this application.
 void setSplashImage(Image splashImage)
          Sets the "splashImage" property of this application.
 void setTitle(String title)
          Sets the "title" property of this application.
 void setTitleBarImage(Image titleBarImage)
          Sets the "titleBarImage" property of this application.
 void setVersionString(String versionString)
          Sets the "versionString" property of this application.
 void showDocument(URL url, String target)
          Shows the URL at the target.
 void unregisterApplet(Applet applet)
           
 void unregisterWindow(Window window)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Application

public Application()
Method Detail

getInstance

public static Application getInstance()
Private constructor so that an Application can't be directly instantated. private Application() { } /** Factory method for obtaining the Application instance associated with this application. The Application object will be instantiated if it does not already exist. This method is intended for use by standalone applications where there may be one and only one JDNCapp instance.

Returns:
Application instance for application

getInstance

public static Application getInstance(Object key)
Factory method for obtaining the Application instance associated with the application designated by the specified key. The Application object will be instantiated if it does not already exist. This method is intended for use by applets, where there may be multiple Application instances in a running VM.

Parameters:
key - object designating the application
Returns:
Application instance for application

getApp

public static Application getApp(Component c)
Convenience method for getting the JDNCapp instance given a component instance. The component instance must be contained in a containent hierarchy which has either a Window or an Applet instance as the root.

Parameters:
c - the ui component
Returns:
Application instance for the specified component's application

getActionManager

public ActionManager getActionManager()
Return the action manager for this application.

Returns:
the action manager instance

setBaseURL

public void setBaseURL(URL baseURL)
Sets the "baseURL" property of this application.

Parameters:
baseURL - URL of codebase for this application

getBaseURL

public URL getBaseURL()
Returns:
URL of codebase for this application

getBaseURL

public static URL getBaseURL(Object obj)
Will retrieve the applet base url if this application is running in an applet. Otherwise, it will try to retrieve the base URL of the xml configuration file.


getURL

public static URL getURL(String value,
                         Object obj)
Fetches a url of a resource value using the clasloader and relative path of obj. Will first try to load from the classpath, then the direct url and then look for a base url.


getURLResource

public static URL getURLResource(String value,
                                 Object obj)

getImage

public static Image getImage(String name,
                             Object obj)

getIcon

public static Icon getIcon(String name,
                           Object obj)

showDocument

public void showDocument(URL url,
                         String target)
Shows the URL at the target.


setSplashImage

public void setSplashImage(Image splashImage)
Sets the "splashImage" property of this application. If set, this image will be rendered in the splash screen which is displayed momentarily at application startup while the application initializes.

Parameters:
splashImage - image displayed in the application's splash screen

getSplashImage

public Image getSplashImage()
Returns:
Image displayed in the application's splash screen

setTitle

public void setTitle(String title)
Sets the "title" property of this application.

Parameters:
title - string containing the title of this application

getTitle

public String getTitle()
Returns:
String containing the title of this application

setTitleBarImage

public void setTitleBarImage(Image titleBarImage)
Sets the "titleBarImage" property of this application. If set, this image will be displayed in the titlebar of all UI windows shown by this application. The placement of this image within the titlebar is Look and Feel dependent.

Parameters:
titleBarImage - image displayed in titlebar of application's toplevel windows

getTitleBarImage

public Image getTitleBarImage()
Returns:
image displayed in titlebar of application's toplevel windows

setVersionString

public void setVersionString(String versionString)
Sets the "versionString" property of this application.

Parameters:
versionString - string containing the version of this application

getVersionString

public String getVersionString()
Returns:
String containing the version of this application

isStandalone

public boolean isStandalone()
Returns true if running as a standalone application and returns false if running ne or more applets.

Returns:
boolean value indicating whether this client is running as a standalone application

isRunningInSandbox

public boolean isRunningInSandbox()
Returns:
boolean value indicating whether or not this application is running in the security sandbox

registerWindow

public void registerWindow(Window window)
Registers a window with the application instance.


unregisterWindow

public void unregisterWindow(Window window)

registerApplet

public void registerApplet(Applet applet)

unregisterApplet

public void unregisterApplet(Applet applet)

getActionMap

public ActionMap getActionMap()
Return the action map associated with this application. The action map holds all the global application actions.


getApplets

public Iterator getApplets()
Returns:
iterator containing all applets registered with this app instance or null if the app was instantiated from a standalone application

getWindows

public Iterator getWindows()
Returns:
iterator containing all windows registered with this app instance or null if there were no toplevel windows registered

addSelectionListener

public void addSelectionListener(SelectionListener l)

removeSelectionListener

public void removeSelectionListener(SelectionListener l)

getSelectionListeners

public SelectionListener[] getSelectionListeners()


Copyright 2004 by Sun Microsystems, Inc. All Rights Reserved.