Initial commit
This commit is contained in:
8
samples/applet/AppTest.html
Normal file
8
samples/applet/AppTest.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<title>Applet Test (1.1)</title>
|
||||
<h1>Applet Test (1.1)</h1>
|
||||
<hr>
|
||||
<applet code=AppTest.class width=400 height=400>
|
||||
</applet>
|
||||
<hr>
|
||||
<a href="AppTest.java">The source.</a>
|
||||
<br>
|
||||
37
samples/applet/AppTest.java
Normal file
37
samples/applet/AppTest.java
Normal file
@@ -0,0 +1,37 @@
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.applet.*;
|
||||
|
||||
import com.jacob.com.*;
|
||||
import com.jacob.activeX.*;
|
||||
|
||||
public class AppTest extends Applet implements ActionListener
|
||||
{
|
||||
TextField in;
|
||||
TextField out;
|
||||
Button calc;
|
||||
ActiveXComponent sC = null;
|
||||
Object sControl = null;
|
||||
|
||||
public void init()
|
||||
{
|
||||
setLayout(new FlowLayout());
|
||||
add(in = new TextField("1+1", 16));
|
||||
add(out = new TextField("?", 16));
|
||||
add(calc = new Button("Calculate"));
|
||||
calc.addActionListener(this);
|
||||
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent ev)
|
||||
{
|
||||
if (sC == null) {
|
||||
String lang = "VBScript";
|
||||
sC = new ActiveXComponent("ScriptControl");
|
||||
sControl = sC.getObject();
|
||||
Dispatch.put(sControl, "Language", lang);
|
||||
}
|
||||
Variant v = Dispatch.call(sControl, "Eval", in.getText());
|
||||
out.setText(v.toString());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user