/*Assignment 3 applet that displays two Labels and two Text Fiels to ask the user to enter two intergers, and then display the sum of the two intergers in the applet window William Burdette July 23, 1997 */ import java.awt.*; import java.applet.Applet; public class Addition extends Applet { Label valuePrompt1; // prompt user to enter first interger TextField value1; // input first interger here Label valuePrompt2; // prompt user to enter second interger TextField value2; // input second interger here int num1, num2, sum; // store input values and sum of intergers /* set up GUI componets initialize varibles */ public void init() { g.drawString ( "This applet will add two intergers.", 30, 30) valuePropmt1 = new Label ("Click on this box and type in interger" ); value1 = new TextFeild ( 10 ); valuePrompt2 = new Label ("Then click on this box, type in an interger and press`ENTER' "); value2 = new TextField (10); add (valuePrompt1); // put prompt 1 on applet add (value1); // put value 1 on applet add (prompt2); // put prompt 2 on applet add (value2); // put value 2 on applet sum = 0; // set sum to 0 } // display results public void paint (Graphic g) { g.drawstring ("The sum of the intergers is :", 70,75); sum = num1 + num2; // add intergers showStatus ( Interger.toString (sum)); //show result } // ?hmmm something fishy here canšt figure it out? public boolean action( Event e, Object o ) { if (event.target == value2) { num1 = Interger.parseInt ( value1.getText () ); num2 = Interger.parseInt ( value2.getText () ); repaint(); } return true; // indicates user's action was proccesed } }