|
Java 6 SE Platform 6.0 Home |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.woven_media.colorsafe.Application
public abstract class Application
Base Application class for Swing apps. Application provides the following functionality:
Application provides a handful of methods that are invoked as part of starting the application. Subclasses need only override those they are interested in. The following outlines the order the methods are invoked in as well as what they are intended for. All methods are invoked on the event dispatching thread.
Nested Class Summary | |
---|---|
private class |
Application.Handler
|
private class |
Application.NotifyingPaintEvent
|
private static class |
Application.SwingThreadFactory
|
Field Summary | |
---|---|
private static Application |
APPLICATION
|
private java.util.List<ApplicationListener> |
appListeners
|
private static boolean |
checkedOS
|
private java.util.Map<java.lang.Object,java.lang.Object> |
data
|
private static boolean |
isOSX
|
private java.util.prefs.Preferences |
preferences
|
private java.util.ResourceBundle |
resources
|
private static int |
RUN_POST_INIT_EVENT_QUEUE_EMPTY
|
private static int |
RUN_START_ON_EDT
|
private static int |
RUN_WAIT_EVENTS
|
private static int |
RUN_WAIT_FOR_BACKGROUND_THREADS
|
private boolean |
started
|
private java.util.concurrent.ThreadFactory |
threadFactory
|
private java.util.List<java.lang.ref.WeakReference<java.lang.Thread>> |
threads
|
private java.lang.Throwable |
throwable
|
private static int |
UNCAUGHT_EXCEPTION
|
Constructor Summary | |
---|---|
Application()
Creates a new Application instance. |
Method Summary | |
---|---|
void |
addApplicationListener(ApplicationListener listener)
Adds a listener for application events. |
protected boolean |
canExit()
Returns whether the application should be allowed to exit. |
protected javax.swing.JDialog |
createBackgroundThreadDialog()
Returns the dialog to show when waiting for any background threads to exit. |
void |
exit()
Exits the application. |
protected void |
exiting()
Invoked as part of exiting the application. |
private void |
fireApplicationDidInit()
|
private void |
fireApplicationExiting()
|
java.util.concurrent.ThreadFactory |
getBackgroundThreadFactory()
Returns a ThreadFactory suitable for threads used within Swing applications. |
java.lang.Object |
getData(java.lang.Object key)
Returns the value for the specified user key. |
static Application |
getInstance()
Returns the single Application instance. |
abstract java.lang.String |
getName()
Returns the name of the application. |
java.util.prefs.Preferences |
getPreferences()
Returns the Preferences object for the Application. |
protected java.lang.Class |
getPreferencesKey()
Returns the Class key used to fetch the Preferences object. |
static java.lang.String |
getResourceAsString(java.lang.String key)
Convenience method to return a resource from the Application as a String. |
java.util.ResourceBundle |
getResourceBundle()
Returns the ResourceBundle for the Application. |
protected java.lang.String |
getResourceBundleName()
Returns the key for loading the resources for the Application. |
protected javax.swing.JDialog |
getUncaughtExceptionDialog()
Returns the dialog that is shown when an uncaught exception is encountered. |
protected void |
init()
Invoked as part of starting the application. |
protected void |
installLookAndFeel()
Invoked from preInit to set the look and feel for the Application. |
static boolean |
isOSX()
Returns true if running on Apple's OS X. |
private boolean |
listenersCanExit()
|
protected void |
postInit()
Invoked as part of starting the application. |
protected void |
postInitEventQueueEmpty()
Invoked as part of starting the application. |
protected void |
preInit()
Invoked as part of starting the application. |
void |
putData(java.lang.Object key,
java.lang.Object value)
Associated the specified value with the specified key. |
void |
registerThread(java.lang.Thread thread)
Registers a background thread with the Application. |
void |
removeApplicationListener(ApplicationListener listener)
Adds a listener for application events. |
void |
start()
Starts the Application. |
private void |
startOnEDT()
|
void |
uncaughtException(java.lang.Thread thread,
java.lang.Throwable throwable)
Invoked when an uncaught exception is encountered. |
void |
uncaughtException(java.lang.Throwable throwable)
Invoked when an uncaught exception is encountered. |
private void |
uncaughtException0()
|
protected void |
waitForBackgroundThreadsToExit()
Blocks until all registered threads have completed. |
private boolean |
waitForBackgroundThreadsToExit(long maxWaitTime)
|
private void |
waitForBackgroundThreadsToExitInBackground(javax.swing.JDialog dialog)
|
private void |
waitForEmptyEventQ()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static Application APPLICATION
private static final int RUN_POST_INIT_EVENT_QUEUE_EMPTY
private static final int RUN_START_ON_EDT
private static final int RUN_WAIT_EVENTS
private static final int UNCAUGHT_EXCEPTION
private static final int RUN_WAIT_FOR_BACKGROUND_THREADS
private static boolean checkedOS
private static boolean isOSX
private java.lang.Throwable throwable
private java.util.concurrent.ThreadFactory threadFactory
private java.util.List<java.lang.ref.WeakReference<java.lang.Thread>> threads
private boolean started
private java.util.prefs.Preferences preferences
private java.util.ResourceBundle resources
private java.util.Map<java.lang.Object,java.lang.Object> data
private java.util.List<ApplicationListener> appListeners
Constructor Detail |
---|
public Application()
java.lang.IllegalStateException
- if an Application has already been createdMethod Detail |
---|
public static Application getInstance()
public static java.lang.String getResourceAsString(java.lang.String key)
key
- the key identifying the resource to obtain
public static boolean isOSX()
public void addApplicationListener(ApplicationListener listener)
listener
- the ApplicationListener to addpublic void removeApplicationListener(ApplicationListener listener)
listener
- the ApplicationListener to addpublic final void putData(java.lang.Object key, java.lang.Object value)
key
- the key to store the value invalue
- the value to associated with keypublic final java.lang.Object getData(java.lang.Object key)
key
- the key used to retrieve the specified value
public final java.util.prefs.Preferences getPreferences()
getPreferencesKey()
protected java.lang.Class getPreferencesKey()
getPreferences()
public final java.util.ResourceBundle getResourceBundle()
getResourceBundleName()
protected java.lang.String getResourceBundleName()
getClass().getName().resources.Resources
.
public java.util.concurrent.ThreadFactory getBackgroundThreadFactory()
When exit is invoked the Application will block until all background threads have exited.
registerThread(java.lang.Thread)
,
waitForBackgroundThreadsToExit()
public final void registerThread(java.lang.Thread thread)
This method is thread safe.
thread
- the Thread to wait for completion on
java.lang.IllegalArgumentException
- if thread is nullpublic abstract java.lang.String getName()
protected void installLookAndFeel()
protected void preInit()
installLookAndFeel()
protected void init()
protected void postInit()
protected void postInitEventQueueEmpty()
public final void start()
main
. Refer to
init sequence for details on which methods
this invokes.
java.lang.IllegalStateException
- if start has already been invokedprivate void startOnEDT()
protected boolean canExit()
exit()
protected void exiting()
private boolean listenersCanExit()
protected void waitForBackgroundThreadsToExit()
exit()
,
createBackgroundThreadDialog()
private void waitForBackgroundThreadsToExitInBackground(javax.swing.JDialog dialog)
private boolean waitForBackgroundThreadsToExit(long maxWaitTime)
private void fireApplicationExiting()
private void fireApplicationDidInit()
public final void exit()
canExit()
,
waitForBackgroundThreadsToExit()
public void uncaughtException(java.lang.Throwable throwable)
throwable
- the thrown exceptionpublic void uncaughtException(java.lang.Thread thread, java.lang.Throwable throwable)
exit
.
uncaughtException
in interface java.lang.Thread.UncaughtExceptionHandler
thread
- the thread the exception was thrown onthrowable
- the thrown exceptiongetUncaughtExceptionDialog()
protected javax.swing.JDialog getUncaughtExceptionDialog()
uncaughtException(java.lang.Throwable)
private void uncaughtException0()
protected javax.swing.JDialog createBackgroundThreadDialog()
private void waitForEmptyEventQ()
|
Java 6 SE Platform 6.0 Home |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |