1import java.awt.Color;
2import java.awt.Graphics;
3
4import javax.swing.JApplet;
5
6
7
8public
9class ParamTest extends JApplet {
10
11 private
12 String p1 = "???", p2 = "!!!", p3 = "the default for p3";
13
14 public
15 void init() {
16 p1 = getParam("dieAntwort", p1);
17 p2 = getParam("dieFrage", p2);
18 p3 = getParam("dieUnbekannte",p3);
19 }
20
21 String getParam(String p, String d) {
22 String r = getParameter(p);
23 return
24 r == null ? d : r;
25 }
26
27
28
29 public
30 void paint( Graphics g ) {
31 setBackground(Color.pink);
32 g.drawString("p1=" + p1 + ", p2=" + p2 + ", p3=" + p3, 25, 25);
33
34 g.drawString("CodeBase:", 25, 45);
35 g.drawString(getCodeBase().toString(), 25, 65);
36
37 g.drawString("DocumentBase:", 25, 85);
38 g.drawString(getDocumentBase().toString(), 25,105);
39
40 showStatus("Applet painted");
41 }
42
43
44
45 public
46 String getAppletInfo() {
47 return "ParamTest.java";
48 }
49
50
51
52 public
53 String [][] getParameterInfo() {
54 String [][] info = {
55 {"dieAntwort", "ein String", "eine Antwort"},
56 {"dieFrage" , "ein String", "eine Frage" }
57 };
58 return info;
59 }
60}