String报错Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException
at logintest.LoginView.ALoginBton(LoginView.java:125)
at logintest.LoginView ALoginBton.actionPerformed(LoginView.java:185)atjavax.swing.AbstractButton.fireActionPerformed(UnknownSource)atjavax.swing.AbstractButton Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access 500(UnknownSource)atjava.awt.EventQueue 3.run(Unknown Source)
at java.awt.EventQueue 3.run(UnknownSource)atjava.security.AccessController.doPrivileged(NativeMethod)atjava.security.ProtectionDomain JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain JavaSecurityAccessImpl.doIntersectionPrivilege(UnknownSource)atjava.awt.EventQueue 4.run(Unknown Source)
at java.awt.EventQueue 4.run(UnknownSource)atjava.security.AccessController.doPrivileged(NativeMethod)atjava.security.ProtectionDomain JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
这里写图片描述

代码段:String uname=userTextField.getText();

出错原因很是无语,因为图省事从别的地方攒来了界面的代码,实际使用的时候发现按钮输入框需要在开头定义一下
如:
JLabel findpsw;
JLabel regnew;
JTextField userTextField;
JPasswordField passTextField;
JButton LBton;

但是原本的
JPasswordField passTextField = new JPasswordField(15);
没有删除前边的JPasswordField
删除则不报错。

定义了两次。。。。具体原因还是说不出

猜你喜欢

转载自blog.csdn.net/guohaocan/article/details/56046376