Package org.fest.swing.launcher
Class AppletLauncher
java.lang.Object
org.fest.swing.launcher.AppletLauncher
Understands a fluent interface for launching and testing
Applet
s.
An applet can be launched by passing its type as String
, the actual type, or an instance of the
applet to launch:
AppletViewer
viewer = AppletLauncher.applet
("org.fest.swing.applet.MyApplet").start
(); // orAppletViewer
viewer = AppletLauncher.applet
(MyApplet.class).start
(); // orAppletViewer
viewer = AppletLauncher.applet
(new MyApplet()).start
();
In addition, we can pass parameters to the applet to launch. The parameters to pass are the same that are specified in the HTML "param" tag:
AppletViewer
viewer = AppletLauncher.applet
(new MyApplet()) .withParameters
(name
("bgcolor").value
("blue"),name
("color").value
("red"),name
("pause").value
("200") ) .start
(); // or Map<String, String> parameters = new HashMap<String, String>(); parameters.put("bgcolor", "blue"); parameters.put("color", "red"); parameters.put("pause", "200");AppletViewer
viewer = AppletLauncher.applet
(new MyApplet()).withParameters
(parameters).start
();
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
add
(AppletParameter parameter) static AppletLauncher
Creates a new applet launcher.static AppletLauncher
Creates a new applet launcher.static AppletLauncher
Creates a new applet launcher.private static UnexpectedException
cannotInstantiateApplet
(String appletType, Exception cause) private static UnexpectedException
cannotLoadType
(String typeName, Exception e) private static AppletLauncher
instantiate
(Class<?> appletType) private static Class<?>
start()
Launches the applet in a
(using implementations ofAppletViewer
andBasicAppletStub
.BasicAppletContext
withParameters
(Map<String, String> newParameters) Sets the parameters for the applet to launch, as an alternative to
.withParameters(AppletParameter...)
withParameters
(AppletParameter... newParameters) Sets the parameters for the applet to launch, as an alternative to
.withParameters(Map)
-
Field Details
-
applet
-
parameters
-
-
Constructor Details
-
AppletLauncher
-
-
Method Details
-
applet
Creates a new applet launcher. The applet to launch is a new instance of the given type. It is assumed that the given type has a default constructor.- Parameters:
appletType
- the type of applet to instantiate.- Returns:
- the created applet launcher.
- Throws:
NullPointerException
- if the given type name isnull
.IllegalArgumentException
- if the given type name is empty.IllegalArgumentException
- if the given type is not a subclass ofjava.applet.Applet
.UnexpectedException
- if the given type cannot be loaded.UnexpectedException
- if a new instance of the given type cannot be instantiated.
-
load
-
cannotLoadType
-
applet
Creates a new applet launcher. The applet to launch is a new instance of the given type. It is assumed that the given type has a default constructor.- Parameters:
appletType
- the type of applet to instantiate.- Returns:
- the created applet launcher.
- Throws:
NullPointerException
- if the given type isnull
.UnexpectedException
- if a new instance of the given type cannot be instantiated.
-
instantiate
-
cannotInstantiateApplet
-
applet
Creates a new applet launcher.- Parameters:
applet
- the applet to launch.- Returns:
- the created applet launcher.
- Throws:
NullPointerException
- if the given applet isnull
.
-
withParameters
Sets the parameters for the applet to launch, as an alternative to
.withParameters(AppletParameter...)
- Parameters:
newParameters
- the parameters for the applet to launch.- Returns:
- this launcher.
- Throws:
NullPointerException
- ifnewParameters
isnull
.
-
withParameters
Sets the parameters for the applet to launch, as an alternative to
.withParameters(Map)
- Parameters:
newParameters
- the parameters for the applet to launch.- Returns:
- this launcher.
- Throws:
NullPointerException
- ifnewParameters
isnull
.NullPointerException
- if any parameter isnull
.
-
add
-
start
Launches the applet in a
(using implementations ofAppletViewer
andBasicAppletStub
. To provide your ownBasicAppletContext
create a newAppletStub
directly. TheAppletViewer
AppletViewer
is created and launched in the event dispatch thread.- Returns:
- the created
AppletViewer
.
-