衬氟隔膜阀英文说明书:JAVA高手请进!有谁能帮我看看这个程序!

来源:百度文库 编辑:中科新闻网 时间:2024/05/05 19:41:10
我要实现点一下按纽,文本框的文字显示在下面
程序如下:
import java.applet.*;
import java.awt.event.*;
import java.awt.*;
public class greet extends Applet implements ActionListener
{ String str2=" ";
String str1;
TextField t1;
Button b1;
public void init()
{setBackground(Color.cyan);
b1=new Button("show");
t1=new TextField(13);
add(t1);
add(b1);
b1.addActionListener(this);
t1.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
str1=e.getActionCommand();
if(str1.equals("show"))
{
str2=(t1.getText());
}

}

public void paint(Graphics g)
{ g.setFont(new Font("verdana", 1, 22));
g.drawString("Hello "+str2+" nice to meet you",200,150);
}
}