package applet;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Boy extends Applet implements ActionListener{
/**
*
*/
private static final long serialVersionUID = 1L;
TextField text1,text2,text3;
public void init()
{
text1=new TextField("input password",20);
//text1.setEditable(false);
text2=new TextField(20);
text2.setEchoChar('*');
text3=new TextField("I am a textfield.",20);
add(text1);
add(text2);
add(text3);
text3.setText("text resetting");
text1.addActionListener(this);
text2.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource() ==text1)
{
String word=text1.getText();
if(word.equals("boy"))
{
text3.setText("nanhai");
}
else if(word.equals("girl"))
{
text3.setText("nvhai");
}
else if(word.equals("sun"))
{
text3.setText("taiyang");
}
else
{
text3.setText("I dont know");
}
}
else if(e.getSource()==text2)
{
String word=text2.getText();
if(word.equals("boy"))
{
text3.setText("t2nanhai");
}
else if(word.equals("girl"))
{
text3.setText("t2nvhai");
}
else if(word.equals("sun"))
{
text3.setText("t2taiyang");
}
else
{
text3.setText("t2I dont know");
}
}
}
}
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Boy extends Applet implements ActionListener{
/**
*
*/
private static final long serialVersionUID = 1L;
TextField text1,text2,text3;
public void init()
{
text1=new TextField("input password",20);
//text1.setEditable(false);
text2=new TextField(20);
text2.setEchoChar('*');
text3=new TextField("I am a textfield.",20);
add(text1);
add(text2);
add(text3);
text3.setText("text resetting");
text1.addActionListener(this);
text2.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource() ==text1)
{
String word=text1.getText();
if(word.equals("boy"))
{
text3.setText("nanhai");
}
else if(word.equals("girl"))
{
text3.setText("nvhai");
}
else if(word.equals("sun"))
{
text3.setText("taiyang");
}
else
{
text3.setText("I dont know");
}
}
else if(e.getSource()==text2)
{
String word=text2.getText();
if(word.equals("boy"))
{
text3.setText("t2nanhai");
}
else if(word.equals("girl"))
{
text3.setText("t2nvhai");
}
else if(word.equals("sun"))
{
text3.setText("t2taiyang");
}
else
{
text3.setText("t2I dont know");
}
}
}
}