|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jgoodies.binding.beans.Model
com.jgoodies.uif.application.Application
public abstract class Application
A base class for Swing applications. It addresses the following issues:
TODO: Consider registering the application as UncaughtExceptionHandler. If an uncaught exception is encountered, the application shall be able to handle it, for example it could show a message dialog or shut down the application.
Constructor Summary | |
---|---|
protected |
Application()
|
Method Summary | |
---|---|
void |
addExitListener(ExitListener listener)
Adds an ExitListener that observes
changes in the application state. |
static void |
clearActionMap(Object target)
Clears the ActionMap cache entry for the given target. |
protected void |
end()
Called by the exit(EventObject) default implementation
to terminate the application. |
void |
exit()
Shuts down this application by calling exit(null) . |
void |
exit(EventObject event)
Notifies registered exit listeners that the application is exiting, then shuts down the application by calling shutdown() . |
boolean |
exitAllowed(EventObject event)
Checks and answers if the application is allowed to exit. |
protected void |
fireApplicationExiting()
Fires an event that indicates that the application is about to exit. |
static Action |
getAction(Object target,
String actionName)
Returns the action named actionName of the given target object. |
static ActionMap |
getActionMap(Object target)
Returns the ActionMap for the given target. |
WindowListener |
getApplicationExitOnWindowClosingHandler()
Lazily creates and returns a handler that invokes Application#exit() on the window closing event. |
static ResourceMap |
getResourceMap(Class<?> type)
Returns the ResourceMap for the given type. |
static void |
launch(Class<? extends Application> appClass,
String... args)
Instantiates the given Application class, initializes the ApplicationContext by setting the Application instance, then invokes #startup with the given arguments. |
void |
removeExitListener(ExitListener listener)
Removes the given ExitListener . |
protected void |
shutdown()
Performs cleanup tasks when the application exits. |
protected abstract void |
startup(String[] args)
Starts this application when the application is launched. |
Methods inherited from class com.jgoodies.binding.beans.Model |
---|
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, equals, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, fireMultiplePropertiesChanged, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected Application()
Method Detail |
---|
public static Action getAction(Object target, String actionName)
actionName
of the given target object.
Equivalent to:
Application.getActionMap(target).get(actionName)
.
Note: Requesting an Action will create
a hard reference to the given target, so it cannot be cleared
by the garbage collector until the ActionMap entry is cleared
using clearActionMap(Object)
.
target
- the instance that will perform the ActionactionName
- used to look up the associated Action method
actionName
of the given target.
IllegalArgumentException
- if the action is absent.public static ActionMap getActionMap(Object target)
ApplicationContext.getInstance().getActionMap(target)
.
Note: Requesting an ActionMap will create
a hard reference to the given target, so it cannot be cleared
by the garbage collector until the ActionMap entry is cleared
using clearActionMap(Object)
.
target
- the object that shall execute the Actions
ApplicationContext.getActionMap(Object)
public static void clearActionMap(Object target)
target
- the key in the ActionMap cache
NullPointerException
- if target
is null
public static ResourceMap getResourceMap(Class<?> type)
ApplicationContext.getInstance().getResourceMap(type)
.
type
- a class to lookup resources for
type
is not null
- otherwise this application's
resource mapApplicationContext.getResourceMap(Class)
public static void launch(Class<? extends Application> appClass, String... args)
#startup
with the given arguments.
Typically this method is called from an application's #main method.
appClass
- the class of the application to launchargs
- optional launch arguments, often the the main method's arguments.shutdown()
,
ApplicationContext.setApplication(Application)
protected abstract void startup(String[] args)
Called by the static launch
method.
launch(Class, String[])
,
shutdown()
protected void shutdown()
startup(String[])
,
exit(EventObject)
,
addExitListener(ExitListener)
public final void exit()
exit(null)
.
This version of #exit() is intended if the application exit
wasn't triggered by an event. Consequently exit listeners
lack the optional event object useful to open dialogs at
the right position or screen.
exit(EventObject)
,
shutdown()
,
addExitListener(ExitListener)
,
removeExitListener(ExitListener)
public void exit(EventObject event)
shutdown()
.
If an exit listener vetoes against the exit, this method does nothing.Exceptions thrown during the exit listener notification and during the shutdown are logged only.
The optional event object is useful for exit listeners that show a dialog; these can use the event object to determine on which screen the dialog shall pop up.
event
- an optional EventObject that triggered the shutdownexit()
,
shutdown()
,
addExitListener(ExitListener)
,
removeExitListener(ExitListener)
protected void end()
exit(EventObject)
default implementation
to terminate the application. This default end
implementation
just invokes System.exit(0)
, which terminates the currently
running Java Virtual Machine.Subclasses may want to override this default behavior to enable multiple Applications running in a JVM, or to let the JVM continue to run after an Application end, for example if the Application is an IDE plug-in.
exit(EventObject)
public final boolean exitAllowed(EventObject event)
event
- an optional event that provides the (event) source
that originated the application exit, useful when opening
a dialog that asks the user whether the exit is allowed or not
public final void addExitListener(ExitListener listener)
ExitListener
that observes
changes in the application state.
listener
- the ExitListener
to add
IllegalArgumentException
- if the listener is nullpublic final void removeExitListener(ExitListener listener)
ExitListener
.
listener
- the ExitListener
to remove
IllegalArgumentException
- if the listener is nullprotected final void fireApplicationExiting()
public final WindowListener getApplicationExitOnWindowClosingHandler()
Application#exit()
on the window closing event.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |