import java.applet.Applet;
import java.awt.Graphics;
import java.awt.*;
import java.awt.event.*;
/*< applet code="P6.class" width="300" height="300">
< param name="msg" value="valid name :[RAJ,VISHNU,PUNEETH]">
< /applet>*/
public class P6 extends Applet implements ActionListener{
Button b1=new Button("GET ADDRESS");
Label l1 =new Label("ENTER NAME");
TextField t1=new TextField(10);
int index = 8;
TextArea area = new TextArea(" ");
// setting location of text area in frame
String address[]={"Doorno 55\n 4th cross \n mysore",
"Doorno 100\n 4th cross \n banglore",
"Doorno 505\n 7th cross \n shivamogga"};
public void init()
{
t1.setText("Name");
area.setBounds(10, 30, 300, 300);
add(l1);
add(t1);
add(area);
add(b1);
b1.addActionListener(this);
}
public void paint(Graphics g){
String str=getParameter("msg");
g.drawString(str,50, 50);
}
public void actionPerformed(ActionEvent ae)
{
if( t1.getText().equals("RAJ"))
index=0;
if( t1.getText().equals("VISHNU"))
index=1;
if( t1.getText().equals("PUNEETH"))
index=2;
if(index<=2)
area.setText(address[index]);
else{
area.setText( "INVALID INPUT \n ENTER VALID NAME");
index=8;
}
repaint();
}
}
/*
*/