01: package com.canoo.webtest.extension.applet.jemmy;
02:
03: import java.awt.Button;
04: import java.awt.FlowLayout;
05: import java.awt.Label;
06: import java.awt.event.ActionEvent;
07: import java.awt.event.ActionListener;
08: import java.net.MalformedURLException;
09: import java.net.URL;
10:
11: /**
12: * @author Denis N. Antonioli
13: */
14: public class Applet extends java.applet.Applet {
15: static final String NAME_BTN = "clickMe";
16: static final String WELCOME = "Welcome to the test Jemmy Applet.";
17: private URL fNextPageUrl;
18:
19: public Applet() {
20: setLayout(new FlowLayout());
21:
22: Label captionLabel = new Label(WELCOME, Label.CENTER);
23: add(captionLabel);
24:
25: Button btn = new Button("button");
26: btn.setName(NAME_BTN);
27: btn.addActionListener(new ActionListener() {
28: public void actionPerformed(ActionEvent e) {
29: String target = getParameter("target");
30: if (target == null) {
31: getAppletContext().showDocument(fNextPageUrl);
32: } else {
33: getAppletContext().showDocument(fNextPageUrl,
34: target);
35: }
36: }
37: });
38: add(btn);
39: }
40:
41: public void init() {
42: showStatus(getParameter("InitialStatus"));
43: try {
44: fNextPageUrl = new URL(getDocumentBase(), "postApplet.html");
45: } catch (MalformedURLException e) {
46: showStatus(e.getMessage());
47: e.printStackTrace();
48: }
49: }
50: }
|