01: package com.canoo.webtest.extension.applet.awt;
02:
03: import java.awt.Button;
04: import java.awt.FlowLayout;
05: import java.awt.Image;
06: import java.awt.Label;
07: import java.awt.event.ActionEvent;
08: import java.awt.event.ActionListener;
09:
10: /**
11: * @author Denis N. Antonioli
12: */
13: public class Applet extends java.applet.Applet {
14: static final String NAME_LBL_BTN_OUTPUT = "field.output";
15: static final String NAME_BTN = "clickMe";
16: static final String NAME_TXT_FIELD = "field.input";
17: static final String NAME_LBL_IMG_SIZE = "image.size";
18:
19: static final String BTN_LBL_BEFORE = "button has not been pushed yet";
20: static final String BTN_LBL_AFTER = "button has been pushed";
21: static final String WELCOME = "Welcome to the test AWT Applet.";
22: static final String INITIAL_SIZE = "unknown size";
23:
24: private final Label fBtnOutputLbl;
25: private final Label fImageSizeLbl;
26:
27: public Applet() {
28: setLayout(new FlowLayout());
29:
30: Label captionLabel = new Label(WELCOME, Label.CENTER);
31: add(captionLabel);
32:
33: fBtnOutputLbl = new Label(BTN_LBL_BEFORE);
34: fBtnOutputLbl.setName(NAME_LBL_BTN_OUTPUT);
35: add(fBtnOutputLbl);
36:
37: Button btn = new Button("button");
38: btn.setName(NAME_BTN);
39: btn.addActionListener(new ActionListener() {
40: public void actionPerformed(ActionEvent e) {
41: fBtnOutputLbl.setText(BTN_LBL_AFTER);
42: }
43: });
44: add(btn);
45:
46: fImageSizeLbl = new Label(INITIAL_SIZE);
47: fImageSizeLbl.setName(NAME_LBL_IMG_SIZE);
48: add(fImageSizeLbl);
49: }
50:
51: public void init() {
52: showStatus(getParameter("InitialStatus"));
53:
54: Image okImage = getImage(getDocumentBase(), "ok.gif");
55: if (okImage != null) {
56: fImageSizeLbl.setText(okImage.getWidth(this ) + "x"
57: + okImage.getHeight(this));
58: }
59: }
60:
61: }
|