|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.rice.comp211.laundry.ui.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.
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 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. |
ThreadFactory |
getBackgroundThreadFactory()
Returns a ThreadFactory suitable for threads used within Swing applications. |
Object |
getData(Object key)
Returns the value for the specified user key. |
static Application |
getInstance()
Returns the single Application instance. |
abstract String |
getName()
Returns the name of the application. |
Preferences |
getPreferences()
Returns the Preferences object for the Application. |
protected Class<? extends Application> |
getPreferencesKey()
Returns the Class key used to fetch the Preferences object. |
static String |
getResourceAsString(String key)
Convenience method to return a resource from the Application as a String. |
ResourceBundle |
getResourceBundle()
Returns the ResourceBundle for the Application. |
protected String |
getResourceBundleName()
Returns the key for loading the resources for the Application. |
protected 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. |
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(Object key,
Object value)
Associated the specified value with the specified key. |
void |
registerThread(Thread thread)
Registers a background thread with the Application. |
void |
removeApplicationListener(ApplicationListener listener)
Adds a listener for application events. |
void |
start()
Starts the Application. |
void |
uncaughtException(Thread thread,
Throwable throwable)
Invoked when an uncaught exception is encountered. |
void |
uncaughtException(Throwable throwable)
Invoked when an uncaught exception is encountered. |
protected void |
waitForBackgroundThreadsToExit()
Blocks until all registered threads have completed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Application()
IllegalStateException
- if an Application has already been createdMethod Detail |
---|
public static Application getInstance()
public static String getResourceAsString(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(Object key, Object value)
key
- the key to store the value invalue
- the value to associated with keypublic final Object getData(Object key)
key
- the key used to retrieve the specified value
public final Preferences getPreferences()
getPreferencesKey()
protected Class<? extends Application> getPreferencesKey()
getPreferences()
public final ResourceBundle getResourceBundle()
getResourceBundleName()
protected String getResourceBundleName()
getClass().getName().resources.Resources
.
public ThreadFactory getBackgroundThreadFactory()
registerThread(java.lang.Thread)
,
waitForBackgroundThreadsToExit()
public final void registerThread(Thread thread)
thread
- the Thread to wait for completion on
IllegalArgumentException
- if thread is nullpublic abstract 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.
IllegalStateException
- if start has already been invokedprotected boolean canExit()
exit()
protected void exiting()
protected void waitForBackgroundThreadsToExit()
exit()
,
createBackgroundThreadDialog()
public final void exit()
canExit()
,
waitForBackgroundThreadsToExit()
public void uncaughtException(Throwable throwable)
throwable
- the thrown exceptionpublic void uncaughtException(Thread thread, Throwable throwable)
exit
.
uncaughtException
in interface Thread.UncaughtExceptionHandler
thread
- the thread the exception was thrown onthrowable
- the thrown exceptiongetUncaughtExceptionDialog()
protected JDialog getUncaughtExceptionDialog()
uncaughtException(java.lang.Throwable)
protected JDialog createBackgroundThreadDialog()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |