home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-02-16 | 1.3 KB | 49 lines |
- import java.awt.*;
- import java.applet.*;
- import MySubClass;
-
- public class Applet20 extends Applet
- {
- MySubClass mySubObject;
- TextField textField1;
- TextField textField2;
-
- public void init()
- {
- mySubObject = new MySubClass(1);
- textField1 = new TextField(10);
- add(textField1);
- textField1.setText("1");
- textField2 = new TextField(10);
- add(textField2);
- textField2.setText("2");
- }
-
- public void paint(Graphics g)
- {
- String s = textField1.getText();
- int value = Integer.parseInt(s);
- mySubObject.SetField(value);
- value = mySubObject.GetField();
- s = String.valueOf(value);
- g.drawString("The myField data field", 30, 80);
- g.drawString("is now set to this value:", 40, 95);
- g.drawString(s, 90, 125);
-
- s = textField2.getText();
- value = Integer.parseInt(s);
- mySubObject.SetNewField(value);
- value = mySubObject.GetNewField();
- s = String.valueOf(value);
- g.drawString("The myNewField data field", 30, 155);
- g.drawString("is now set to this value:", 40, 170);
- g.drawString(s, 90, 200);
- }
-
- public boolean action(Event event, Object arg)
- {
- repaint();
- return true;
- }
- }
-