到底哪儿错了?
import javax.swing.*;import javax.swing.text.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.JOptionPane;
public class B
{ public static void main(String args[])
{ new Win();
}
}
class DigitDocumnet extends PlainDocument
{ int count=1;
public void insertString(int offset,String s,AttributeSet a)
{ char c=s.charAt(0);
if(c<='9'&&c>='0'&&count<=10)
{ try { super.insertString(offset,s,a);
count++;
}
catch(BadLocationException e){}
}
}
public void remove(int offset,int length)
{ try
{ super.remove(offset,length);
count--;
}
catch(BadLocationException e){}
}
}
class Win extends JFrame implements ActionListener
{ JTextField text,text1;
JLabel jlabel1,jlabel2;
DigitDocumnet document;
public Win()
{ setBounds(100,100,300,200);
setVisible(true);
text=new JTextField(20);
text1=new JTextField(20);
Container con=getContentPane();
con.setLayout(new FlowLayout());
jlabel1=new JLabel("学号");
jlabel2=new JLabel("姓名");
con.add(jlabel1);
document=new DigitDocumnet();
text.setDocument(document);
con.add(text);
con.add(jlabel2);
con.add(text1);
text1.addActionListener(this);
text.requestFocus();
con.validate();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==text1)
{
if((text.getText()).equals("1234567890")&&(texe1.gettext()).equals("wangde"))
JOptionPane.showMessageDialog(this,"登陆",JOptionPane.WARNING_MESSAGE);
else if
JOptionPane.showMessageDialog(this,"用户名或密码错误",JOptionPane.WARNING_MESSAGE);
}
}
}