java.awt.eventqueue_【求助】 "AWT-EventQueue-0" java.lang.NullPointerException

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

主界面

import java.awt.Button;

import java.awt.FlowLayout;

import java.awt.Frame;

import java.awt.TextArea;

import java.awt.TextField;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.KeyAdapter;

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import java.awt.*;

public class Mouse_event {

/**

* @param args

*/

private Frame f;

private TextField tf;

private Button but1;

private Button but2;

private Label la;

private TextArea tex;

public Mouse_event() {

init();

// TODO Auto-generated constructor stub

}

private void init() {

// TODO Auto-generated method stub

f = new Frame("本体工具");

f.setBounds(200, 200,400, 400);

f.setLayout(new FlowLayout());

la = new Label("本体展示及编辑",la.CENTER);

tf = new TextField(50);

but1 = new Button("添加本体");

but2 = new Button("开始分析");

tex = new TextArea("",10, 50,TextArea.SCROLLBARS_VERTICAL_ONLY);

f.add(la);

f.add(tf);

f.add(but1);

f.add(but2);

f.add(tex);

f.setVisible(true);

MyEvent();

}

public String[] OloN = new String[100];

public int i;

private void MyEvent() {

// TODO Auto-generated method stub

f.addWindowListener(new WindowAdapter() {

@Override

public void windowClosing(WindowEvent e) {

// TODO Auto-generated method stub

System.exit(0);

}

});

but1.addMouseListener(new MouseAdapter() {

@Override

public void mouseClicked(MouseEvent e) {

// TODO Auto-generated method stub

OloN[i] = tf.getText();

String zt = "添加了本体"+tf.getText()+" ";

tex.setText(zt+tex.getText());

i++;

}

});

//but2.addActionListener(new ActionListener() {

//

//@Override

//public void actionPerformed(ActionEvent e) {

TODO Auto-generated method stub

//f.dispose();

//new form1();

//

//}

//});

but2.addMouseListener(new MouseAdapter() {

@Override

public void mouseClicked(MouseEvent e) {

// TODO Auto-generated method stub

f.dispose();

new form1();

}

});

}

public static void main(String[] args) {

// TODO Auto-generated method stub

new Mouse_event();

}

}

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at Forms.ReturnBook.actionPerformed(ReturnBook.java:112) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.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(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.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)进行修改
06-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值