public class AppletLauncher extends Object
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.assertj.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
();
Modifier and Type | Method and Description |
---|---|
static AppletLauncher |
applet(Class<? extends Applet> appletType)
Creates a new
AppletLauncher . |
static AppletLauncher |
applet(String appletType)
Creates a new
AppletLauncher . |
static AppletLauncher |
launcherFor(Applet applet)
Creates a new
AppletLauncher . |
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...) . |
@RunsInEDT @Nonnull public static AppletLauncher applet(@Nonnull String appletType)
AppletLauncher
. The Applet
to launch is a new instance of the given type. It is
assumed that the given type has a default constructor.appletType
- the type of Applet
to instantiate.AppletLauncher
.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 Applet
.UnexpectedException
- if the given type cannot be loaded.UnexpectedException
- if a new instance of the given type cannot be instantiated.@RunsInEDT @Nonnull public static AppletLauncher applet(@Nonnull Class<? extends Applet> appletType)
AppletLauncher
. The Applet
to launch is a new instance of the given type. It is
assumed that the given type has a default constructor.appletType
- the type of Applet
to instantiate.AppletLauncher
.NullPointerException
- if the given type is null
.UnexpectedException
- if a new instance of the given type cannot be instantiated.@Nonnull public static AppletLauncher launcherFor(@Nonnull Applet applet)
AppletLauncher
.applet
- the Applet
to launch.AppletLauncher
.NullPointerException
- if the given Applet
is null
.@Nonnull public AppletLauncher withParameters(@Nonnull Map<String,String> newParameters)
Applet
to launch, as an alternative to
withParameters(AppletParameter...)
.newParameters
- the parameters for the Applet
to launch.NullPointerException
- if newParameters
is null
.@Nonnull public AppletLauncher withParameters(@Nonnull AppletParameter... newParameters)
Applet
to launch, as an alternative to withParameters(Map)
.newParameters
- the parameters for the Applet
to launch.NullPointerException
- if newParameters
is null
.NullPointerException
- if any parameter is null
.@Nonnull public AppletViewer start()
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 (EDT).AppletViewer
.Copyright © 2014–2019 AssertJ. All rights reserved.