org.fest.swing.launcher
Class AppletLauncher

java.lang.Object
  extended by org.fest.swing.launcher.AppletLauncher

public class AppletLauncher
extends Object

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:

 AppletViewer viewer = AppletLauncher.applet("org.fest.swing.applet.MyApplet").start();

 // or


 AppletViewer viewer = AppletLauncher.applet(MyApplet.class).start();

 // or

 AppletViewer 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();


 

Author:
Yvonne Wang, Alex Ruiz

Method Summary
static AppletLauncher applet(Applet applet)
          Creates a new applet launcher.
static AppletLauncher applet(Class<? extends Applet> appletType)
          Creates a new applet launcher.
static AppletLauncher applet(String appletType)
          Creates a new applet launcher.
 AppletViewer start()
          Launches the applet in a AppletViewer (using implementations of BasicAppletStub and BasicAppletContext.
 AppletLauncher withParameters(AppletParameter... newParameters)
          Sets the parameters for the applet to launch, as an alternative to withParameters(Map).
 AppletLauncher withParameters(Map<String,String> newParameters)
          Sets the parameters for the applet to launch, as an alternative to withParameters(AppletParameter...)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

applet

@RunsInEDT
public static AppletLauncher applet(String appletType)
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 is null.
IllegalArgumentException - if the given type name is empty.
IllegalArgumentException - if the given type is not a subclass of java.applet.Applet.
UnexpectedException - if the given type cannot be loaded.
UnexpectedException - if a new instance of the given type cannot be instantiated.

applet

@RunsInEDT
public static AppletLauncher applet(Class<? extends Applet> appletType)
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 is null.
UnexpectedException - if a new instance of the given type cannot be instantiated.

applet

public static AppletLauncher applet(Applet applet)
Creates a new applet launcher.

Parameters:
applet - the applet to launch.
Returns:
the created applet launcher.
Throws:
NullPointerException - if the given applet is null.

withParameters

public AppletLauncher withParameters(Map<String,String> newParameters)
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 - if newParameters is null.

withParameters

public AppletLauncher withParameters(AppletParameter... newParameters)
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 - if newParameters is null.
NullPointerException - if any parameter is null.

start

public AppletViewer start()
Launches the applet in a AppletViewer (using implementations of BasicAppletStub and BasicAppletContext. To provide your own AppletStub create a new AppletViewer directly. The AppletViewer is created and launched in the event dispatch thread.

Returns:
the created AppletViewer.


Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.