6.
Write a Java Program to create a frame with four text fields name, street, city and pin code
with suitable tables. Also add a button called my details. When the button is clicked its
corresponding values are to be appeared in the text fields.
Algorithm:
Aim: Creation of a frame with four text fields name, street, city and pin code with suitable tables
and adding a button called my details. When clicking the button its corresponding values are
to be appeared in respective text fields.
Step No. Instructions
1 Start
2 Create an Frame called “list6” by
a) Inheriting the Frame class
b) Implementing the Interface namely WindowsListener and ActionListener
4 Create 4 text fields namely, tname, tstreet, tcity and tpin using TextField( ) function
5 Create 4 labels namely, lname, lstreet, lcity and lpin using Label( ) function
6 Add all the labels and textfields in the Frame using add( ) fucntion
7 Create a button called Mydet
8 Use addActionListener( ) function for the button
9 Catch the Action Event for button using getSource( ) function and set the texts for
each text field using setText( ) function
Catch the Window Events for window opearations using windowDeiconified( ),
windowIconified( ), windowOpened( ), windowActivated( ) and
windowDeactivated() functions
10 Save the Frame code in the name of list6.java
11 Compile the Applet code using javac
12 Create a HTML code with <APPLET> tag with its CODE attribute as list6.class
13 Save the HTML code as list6.html
14 Run the HTML code using appletviewer
15 Stop