我在按下java中的按鈕重置時出錯。更新:我已經在設計視圖的LoginForm.java中創建了一個JTextField和JPasswordField,它是textField1和passwordField1,事情是我想在ResetField.java中訪問它。Java中的ResetField
這裏是我的代碼:
public class ResetField
{
JTextField textField1;
JPasswordField passwordField1;
public void ResetAction()
{
textField1.setText("");
passwordField1.setText("");
}
}
private void button2ActionPerformed(java.awt.event.ActionEvent evt) {
_resetField.ResetAction();
}
以下是錯誤的文字:
在 inspection.management異常在線程 「AWT-EventQueue的-0」 顯示java.lang.NullPointerException 。 system.ResetField.ResetAction(ResetField.java:17) at inspection.management.system.LoginForm.button2ActionPerformed(LoginForm.java:170) at inspection.man agement.system.LoginForm.access $ 100(LoginForm.java:10) 在 inspection.management.system.LoginForm $ 2.actionPerformed(LoginForm.java:73) 在 javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java: 2018) 在 javax.swing.AbstractButton中的$ Handler.actionPerformed(AbstractButton.java:2341) 在 javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) 在 javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel .java:259) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) at java.awt.Component.processMouseEvent( Component.java:6505)在 javax.swing.JComponent.processMouseEvent(JComponent.java:3320)處 java.awt.Container.processEvent java.awt.Component.processEvent(Component.java:6270)(容器。的java:2229)在 java.awt.Component.dispatchEventImpl(Component.java:4861)在 java.awt.Container.dispatchEventImpl(Container.java:2287)在 java.awt.Component.dispatchEvent(Component.java: 4687)在 java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832) 在 java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492) 在java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422 ) at java.awt.Container.dispatchEventImpl(Containe r.java:2273)at java.awt.Window.dispatchEventImpl(Window.java:2719)at java.awt.Component.dispatchEvent(Component.java:4687)at java.awt.EventQueue.dispatchEventImpl(EventQueue。 (EventQueue.java:103)at java.awt.EventQueue $ 3.run的.java:692)在 java.security.AccessController.doPrivileged(本機方法)在 java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:76) 在 java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java :87) at java.awt.EventQueue $ 4.run(EventQueue.java:708)at java.awt.EventQueue $ 4.run(EventQueue.java:706)at java.security.AccessController.doPrivileged(Native Method)at java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:76) at java。 awt.EventQueue.dispatchEvent(EventQueue.java:705)at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread。的java:161) 在 java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) 在 java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) 在 java.awt.EventDispatchThread.pumpEvents(EventDispatchThread的.java:138) 在java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
無法閱讀。您能否將錯誤的前幾行作爲文本加入? – 2013-11-15 15:51:17
複製並粘貼錯誤,該圖像太難閱讀。 – turbo
你現在可以刪除圖像;) – MariuszS