home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-02-19 | 1.2 KB | 44 lines |
- import java.awt.*;
- import java.applet.*;
- import TestSubClass;
-
- public class ClassApplet extends Applet
- {
- TestSubClass testSubObject;
- TextField textField1;
- TextField textField2;
-
- public void init()
- {
- testSubObject = new TestSubClass(1, "Default String");
- textField1 = new TextField(25);
- add(textField1);
- textField1.setText("Default String");
- textField2 = new TextField(5);
- add(textField2);
- textField2.setText("1");
- }
-
- public void paint(Graphics g)
- {
- String s = textField1.getText();
- testSubObject.SetData(s);
- s = textField2.getText();
- int value = Integer.parseInt(s);
- testSubObject.SetData2(value);
-
- g.drawString("Enter a string for data1 in", 30, 80);
- g.drawString("the first box and an integer", 30, 95);
- g.drawString("for data2 in the second box.", 30, 110);
- g.drawString("Here is the complete data string:", 25, 160);
- s = testSubObject.CreateDataString();
- g.drawString(s, 50, 180);
- }
-
- public boolean action(Event event, Object arg)
- {
- repaint();
- return true;
- }
- }
-