编译通过,但是运行不出来,出来好多异常,不知道什么意思。。谢谢
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class EightPointOne implements ActionListener
{
JFrame f;
JLabel l1,l2;
JTextField tf1,tf2;
JButton b1,b2,b3;
JPanel p1,p2;
public static void main(String args[])
{
EightPointOne epo=new EightPointOne();
epo.go();
}
public void go()
{
f=new JFrame("My Frame");
l1=new JLabel("Source");
l2=new JLabel("Target");
b1=new JButton("Clear");
b2=new JButton("Copy");
b3=new JButton("Close");
p1=new JPanel();
p1.setLayout(new GridLayout(2,2));
p1.add(l1);
p1.add(tf1);
p1.add(l2);
p1.add(tf2);
p2=new JPanel();
p2.setLayout(new GridLayout(1,3));
p2.add(b1);
p2.add(b2);
p2.add(b3);
f.getContentPane().add(p1,"Center");
f.getContentPane().add(p2,"South");
f.setSize(300,300);
f.setVisible(true);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
JButton b=(JButton)e.getSource();
if(b==b1)
{
tf1.setText("");
tf2.setText("");
}
else if(b==b2)
{
String s=tf1.getText();
tf2.setText(s);
}
else
System.exit(0);
}}