blob: d2a7acf056c06a4dadd8ef3687fc7606bd8b2749 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
import java.applet.Applet;
import java.util.Arrays;
import netscape.javascript.JSObject;
public class JavascriptGet extends Applet {
public DummyObject dummyObject = new DummyObject("DummyObject1");
public Object value;
private JSObject window;
private final String jsvar = "jsvar";
public void init() {
window = JSObject.getWindow(this);
String initStr = "JToJSGet applet initialized.";
System.out.println(initStr);
}
// methods for testing read from JavaScript variables
public void jjsReadInt() {
// value = new Integer(window.getMember(jsvar).toString());
int num = ((Number) window.getMember(jsvar)).intValue();
System.out.println(value);
}
public void jjsReadDouble() {
value = new Double(window.getMember(jsvar).toString());
System.out.println(value);
}
public void jjsReadBoolean() {
value = new Boolean(window.getMember(jsvar).toString());
System.out.println(value);
}
public void jjsReadString() {
value = window.getMember(jsvar).toString();
System.out.println(value);
}
public void jjsReadObject() {
value = window.getMember(jsvar).toString();
System.out.println(value);
}
public void jjsRead1DArray() {
Object[] arrayvalue = (Object[]) window.getMember(jsvar);
System.out.println(Arrays.toString(arrayvalue));
}
public void jjsRead2DArray() {
Object[][] arrayvalue = (Object[][])window.getMember(jsvar);
System.out.println(Arrays.deepToString(arrayvalue));
}
public void jjsReadJSObject() {
JSObject jsobjectvalue = (JSObject) window.getMember(jsvar);
System.out.println(jsobjectvalue);
}
//auxiliary class DummyObject
public class DummyObject {
private String str;
public DummyObject(String s) {
this.str = s;
}
public void setStr(String s) {
this.str = s;
}
public String toString() {
return str;
}
}
//auxiliary methods:
public DummyObject getNewDummyObject(String s){
return new DummyObject(s);
}
public void writeAfterTests(){
System.out.println("afterTests");
}
}
|