错了 来看看
import javax.swing.*;import java.awt.*;
import java.awt.event.*;
public class MainPane extends JFrame implements ActionListener
{
public static void main(String[] args)
{
JFrame f=new JFrame("登入窗口");
JLabel l1=new JLabel("用户名");
JLabel l2=new JLabel("密 码");
JTextField jt=new JTextField(10);
JPasswordField fp=new JPasswordField(10);
JButton b1=new JButton("确定");
b1.addActionListener(this);
JButton b2=new JButton("取消");
JButton b3=new JButton("about");
Container contentPane=f.getContentPane();
contentPane.setLayout(new GridLayout(3,1));
JPanel p1=new JPanel();
JPanel p2=new JPanel();
JPanel p3=new JPanel();
f.add(p1);
f.add(p2);
f.add(p3);
p1.add(l1);
p1.add(jt);
p2.add(l2);
p2.add(fp);
p3.add(b1);
p3.add(b2);
p3.add(b3);
f.setBounds(100,100,250,150);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == b1)
{
JOptionPane.showMessageDialog(null,"extends err","heh",JOptionPane.INFORMATION_MESSAGE);
}
}
}