锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
import java.applet.*;
import java.awt.event.*;
public class myjava3
{
public static void main(String [] agrs)
{
new myjava3_1( ) ;
}
}
class myjava3_1 extends Frame implements ActionListener
{
Label p1;
TextField p2,p3;
Button btn;
myjava3_1()
{
super("鏉庝笘鏄ョ殑鍥懼儚鐣岄潰");
p1=new Label("璇瘋緭鍏ヤ綘鐨勫悕瀛楋紝璋㈣阿錛?);
p2=new TextField(20);
p3=new TextField(35);
btn=new Button("鍏抽棴鏈獥鍙?);
setLayout(new FlowLayout());
add(p1);
add(p2);
add(p3);
add(btn);
p2.addActionListener(this);
btn.addActionListener(this);
setSize(300,200);
show();
};
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==p2)
{ p3.setText(p2.getText()+",welcome !");}
else
{
dispose();
System.exit(1);
}
}
}
緇ф壙浜?Frame 綾?
public class myjava03 extends Frame implements ActionListener
setLayout( new FlowLayout() );
input.actionListener(this)
btn.actionListener(this)
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==p2)
{ p3.setText(p2.getText()+",welcome !");}
else
{
dispose();
System.exit(1);
}
}
}
actionPerformed(ActionEvent e)
e.getSource== input 鍒ゆ柇鏄惁鏄痠nput 杈撳叆銆?BR>