小弟写的java程序有点问题呢!!请哥哥帮忙指点下、、

来源:百度知道 编辑:UC知道 时间:2024/06/04 10:14:33
import java.awt.*;
import java.awt.event.*;
public class Fuzhi extends Frame implements ActionListener
{
TextField tf=new TextField();
Button btn=new Button("复制");
Label b1=new Label();

Fuzhi()
{
super("将文本框的内容复制到标签中");
setSize(150,300);
setVisible(true);
setLayout(new GridLayout(3,1));
add(tf);
add(btn);
add(b1);
btn.addActionListener(this);
addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e)
{System.exit(0);}
});
validate();

}

public void actionPerformed(ActionEvent e)
{
if(e.getSource()==btn)
{b1=tf.getText();
}
}
public static void main(String args[])
{

import java.awt.*;
import java.awt.event.*;
public class Fuzhi extends Frame implements ActionListener
{
TextField tf=new TextField();
Button btn=new Button("复制");
Label b1=new Label();

Fuzhi()
{
super("将文本框的内容复制到标签中");
setSize(150,300);
setVisible(true);
setLayout(new GridLayout(3,1));
add(tf);
add(btn);
add(b1);
btn.addActionListener(this);
addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e)
{System.exit(0);}
});
validate();

}

public void actionPerformed(ActionEvent e)
{
if(e.getSource()==btn)
{b1.setText(tf.getText());
}
}
public static void main(String args[])