Package org.fest.swing.launcher
Class AppletLauncher
java.lang.Object
org.fest.swing.launcher.AppletLauncher
Understands a fluent interface for launching and testing
Applets.
An applet can be launched by passing its type as String, the actual type, or an instance of the
applet to launch:
AppletViewerviewer = AppletLauncher.applet("org.fest.swing.applet.MyApplet").start(); // orAppletViewerviewer = AppletLauncher.applet(MyApplet.class).start(); // orAppletViewerviewer = 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:
AppletViewerviewer = 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");AppletViewerviewer = AppletLauncher.applet(new MyApplet()).withParameters(parameters).start();
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidadd(AppletParameter parameter) static AppletLauncherCreates a new applet launcher.static AppletLauncherCreates a new applet launcher.static AppletLauncherCreates a new applet launcher.private static UnexpectedExceptioncannotInstantiateApplet(String appletType, Exception cause) private static UnexpectedExceptioncannotLoadType(String typeName, Exception e) private static AppletLauncherinstantiate(Class<?> appletType) private static Class<?>start()Launches the applet in a(using implementations ofAppletViewerandBasicAppletStub.BasicAppletContextwithParameters(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- ifnewParametersisnull.
-
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- ifnewParametersisnull.NullPointerException- if any parameter isnull.
-
add
-
start
Launches the applet in a(using implementations ofAppletViewerandBasicAppletStub. To provide your ownBasicAppletContextcreate a newAppletStubdirectly. TheAppletViewerAppletVieweris created and launched in the event dispatch thread.- Returns:
- the created
AppletViewer.
-