Getting Input from the User in Java Applet

Applets work in graphical environment. Therefore applets treat input as text strings. We must first create an area of the screen in which user can type and edit input items. We can do this by using the TextField class of the applet package. The values of the fields can be given even editer after the creation of input fields. Next step is to retrieve the items from the fields for display of calculations.

For any kinds of computation on the input field, we must convert it to the right form and the resuls again converted back to strings for display.

Let us consider an example


This applet runs using the following HTML file:



Note :- after comipling this applet program will not calculate the two variables a and b because for this we need event programming...


"Output of GettingInputfromtheUser.class"


Download Complete Program

  -     -   HTML File





No comments:

Post a Comment