Java Tutorial

import java.awt.*;
import java.applet.*;

public class UserInput extends Applet
      TextField text1, text2;

      public void init()
           text1 = new TextField(8);
           text2 = new TextField(8);

      public void paint(Graphics g)
          int x=0,y=0,z=0;
          String s1,s2,s;
          g.drawString(\"Input a number in each box  \",10,50);
                 s1 = text1.getText();
                 x = Integer.parseInt(s1);
                 s2 = text2.getText();
                 y = Integer.parseInt(s2);
          catch(Exception e) {}

           z = x + y;
           s =  String.valueOf(z);
           g.drawString(\"The Sum is : \",10,75);

    public boolean action(Event event, Object obj)
          return true;

    Related Post:
  1. Program to show an example of creating a class and using its object

  2. Program to show an example of using a Static Nested Class outside the Top-Level Class

  3. GUI application in java, which enter the details of a student and on the submit display the details of the student

  4. Program of storing and retrieving integers using data streams on a single file

  5. Program that accepts a shopping list of five items from the command line and stores them in vector

  6. Program which will read a string and rewrite it in the alphabetical order

  7. Program to read the ballots and count the votes cast for each candidate using an array variable count

  8. Game application in CORBA for which player will guess a number between 1 to 100, which will be compared to the random number generated by the class

  9. Program of date server and client

  10. An applet program showing Clicked Event on canvas

  11. RMI based application, which reads a file with list of marks of student from a client, send it to server and find how many students having distinct

  12. An applet program to display Vertical Color Bar

  13. Program to show the use of Increment and Decrement Operators

  14. An applet program to draw concentric circle in center of the canvas

  15. Program of inventory management and demonstrating interactive input and output

  16. Program to show the use of Bitwise Operator (~) Complement

  17. Program to show the use of operator (>>) Shift Right, propagating the sign bit from the left

  18. An applet program to find maximum of three numbers using textField

  19. Write a class whose objects holds a current value and have a method to add that value, printing the new value

  20. Program to perform Merge Sort

Didn't find what you were looking for? Find more on An applet program to take user input and display