Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at TalkClientFace$1.actionPerformed(TalkClient.java:144)
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.AWTEventMulticaster.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$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$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)
错误代码如下:
search.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Infos.clear();
boolean [] state = {check1.isSelected(),check2.isSelected(),check3.isSelected(),check4.isSelected(),check5.isSelected()};
try {
int n;
n = mydata.bytime(building.getSelectedIndex(), day.getSelectedIndex()+1, state, Infos);
System.out.println("add driver successful");
if(n == 0) JOptionPane.showMessageDialog(null,"没有找到符合要求的自习室","没有找到",JOptionPane.WARNING_MESSAGE);
else JOptionPane.showMessageDialog(null,"找到"+n+"个符合要求的自习室","查找结果",JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException e1) {
// TODO 自动生成 catch 块
e1.printStackTrace();
}
//System.out.println(Infos);
table.updateUI();
}
});
求高手帮一下忙
6 个解决方案
#1
可能问题出在
boolean [] state = {check1.isSelected(),check2.isSelected(),check3.isSelected(),check4.isSelected(),check5.isSelected()};
NullPointerException一般都是array搞出来的。
boolean [] state = {check1.isSelected(),check2.isSelected(),check3.isSelected(),check4.isSelected(),check5.isSelected()};
NullPointerException一般都是array搞出来的。
#2
14Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at TalkClientFace$1.actionPerformed(TalkClient.java:144)
144是哪一行,楼主。
at TalkClientFace$1.actionPerformed(TalkClient.java:144)
144是哪一行,楼主。
#3
是这一行
n = mydata.bytime(building.getSelectedIndex(), day.getSelectedIndex()+1, state, Infos);
#4
能具体说一下吗
#5
你看看bytime方法是不是要一个空的Infos对象做参数
你之前调用了Infos.clear();
你之前调用了Infos.clear();
#6
是要一个空的Infos对象做参数
#1
可能问题出在
boolean [] state = {check1.isSelected(),check2.isSelected(),check3.isSelected(),check4.isSelected(),check5.isSelected()};
NullPointerException一般都是array搞出来的。
boolean [] state = {check1.isSelected(),check2.isSelected(),check3.isSelected(),check4.isSelected(),check5.isSelected()};
NullPointerException一般都是array搞出来的。
#2
14Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at TalkClientFace$1.actionPerformed(TalkClient.java:144)
144是哪一行,楼主。
at TalkClientFace$1.actionPerformed(TalkClient.java:144)
144是哪一行,楼主。
#3
是这一行
n = mydata.bytime(building.getSelectedIndex(), day.getSelectedIndex()+1, state, Infos);
#4
能具体说一下吗
#5
你看看bytime方法是不是要一个空的Infos对象做参数
你之前调用了Infos.clear();
你之前调用了Infos.clear();
#6
是要一个空的Infos对象做参数