Class Spin
Spin offers a transparent threading solution for developing non-freezing Swing applications.
Let bean be a reference to a non-visual (possibly
multithreaded) bean implementing the interface Bean whose
methods have to be called by a Swing component. You can avoid any freezing by
using one line of code:
bean = (Bean) Spin.off(bean);Now each method call on
bean is executed on a separate thread,
while the EDT is continuing to dispatch events. All return values or
exceptions are handled by Spin and transparently returned to the
calling method.
For calls from other threads than the EDT to your Swing component you can use
the following (being
bean.addXYListener((XYListener)Spin.over(component);
Now all required updates to your component (and/or its model) are
transparently excuted on the EDT.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic EvaluatorGet the default evaluator for spin-off.static EvaluatorGet the default evaluator for spin-over.static ProxyFactoryGet the default proxy factory.getProxy()Get a proxy for the wrapped object.static ObjectConvenience method to spin-off the given object from Swing.static ObjectConvenience method to spin-over the given object with Swing.static voidsetDefaultOffEvaluator(Evaluator evaluator) Set the default evaluator for spin-off.static voidsetDefaultOverEvaluator(Evaluator evaluator) Set the default evaluator for spin-over.static voidsetDefaultProxyFactory(ProxyFactory factory) Set the default factory of proxies.
-
Constructor Details
-
Spin
Create a Spin wrapper for the given object.- Parameters:
object- object to wrapevaluator- evaluator of invocations on the given object
-
Spin
Create a Spin wrapper for the given object.- Parameters:
object- object to wrapproxyFactory- factory for a proxyevaluator- evaluator of invocations on the given object
-
-
Method Details
-
getProxy
Get a proxy for the wrapped object.
The returned object can safely be casted to any interface the wrapped object implements.- Returns:
- the new proxy
-
off
Convenience method to spin-off the given object from Swing.
The returned object can safely be casted to any interface the given object implements.
- Parameters:
object- the object to spin-off- Returns:
- proxy for the given object
- See Also:
-
over
Convenience method to spin-over the given object with Swing.
The returned object can safely be casted to any interface the given object implements.- Parameters:
object- the object to spin-over- Returns:
- proxy for the given object
- See Also:
-
setDefaultProxyFactory
Set the default factory of proxies.- Parameters:
factory- proxy factore to use as default
-
setDefaultOffEvaluator
Set the default evaluator for spin-off.- Parameters:
evaluator- evaluator to use for spin-off
-
setDefaultOverEvaluator
Set the default evaluator for spin-over.- Parameters:
evaluator- evaluator for spin-over
-
getDefaultProxyFactory
Get the default proxy factory.- Returns:
- the default factory of proxies
-
getDefaultOffEvaluator
Get the default evaluator for spin-off.- Returns:
- evaluator for spin-off
-
getDefaultOverEvaluator
Get the default evaluator for spin-over.- Returns:
- evaluator for spin-over
-