错误:
线程“AWT-EventQueue-0”中的异常java.lang.NullPointerException 在leapp.BehemothSelectGUI.cmbMothHeadActionPerformed(BehemothSelectGUI.java:141) at leapp.BehemothSelectGUI.access $ 100(BehemothSelectGUI.java:12) at leapp.BehemothSelectGUI $ 2.actionPerformed(BehemothSelectGUI.java:61) 在javax.swing.JComboBox.fireActionEvent(JComboBox.java:1258) 在javax.swing.JComboBox.contentsChanged(JComboBox.java:1332) 在javax.swing.JComboBox.intervalRemoved(JComboBox.java:1352) 在javax.swing.AbstractListModel.fireIntervalRemoved(AbstractListModel.java:179) 在javax.swing.DefaultComboBoxModel.removeAllElements(DefaultComboBoxModel.java:174) 在javax.swing.JComboBox.removeAllItems(JComboBox.java:771) 在leapp.Populate.cmbPop(Populate.java:52) 在leapp.BehemothSelectGUI。(BehemothSelectGUI.java:25) 在leapp.HeroSelectGUI.btnChooseMothActionPerformed(HeroSelectGUI.java:170) 在leapp.HeroSelectGUI.access $ 000(HeroSelectGUI.java:14) 在leapp.HeroSelectGUI $ 1.actionPerformed(HeroSelectGUI.java:78) 在javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022) 在javax.swing.AbstractButton $ Handler.actionPerformed(AbstractButton.java:2348) 在javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) 在javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) 在javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) at java.awt.Component.processMouseEvent(Component.java:6533) 在javax.swing.JComponent.processMouseEvent(JComponent.java:3324) at java.awt.Component.processEvent(Component.java:6298) at java.awt.Container.processEvent(Container.java:2236) at java.awt.Component.dispatchEventImpl(Component.java:4889) at java.awt.Container.dispatchEventImpl(Container.java:2294) at java.awt.Component.dispatchEvent(Component.java:4711) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466) at java.awt.Container.dispatchEventImpl(Container.java:2280) at java.awt.Window.dispatchEventImpl(Window.java:2746) at java.awt.Component.dispatchEvent(Component.java:4711) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758) at java.awt.EventQueue.access $ 500(EventQueue.java:97) at java.awt.EventQueue $ 3.run(EventQueue.java:709) at java.awt.EventQueue $ 3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain $ JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain $ JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) at java.awt.EventQueue $ 4.run(EventQueue.java:731) at java.awt.EventQueue $ 4.run(EventQueue.java:729) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain $ JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:728) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) 建立成功(总时间:7秒)
我正在尝试从用户选择的组合框中获取所选项目并获取该项目,并将其数据库值(如“HitPoints”)存储为整数。
private void cmbMothHeadActionPerformed(java.awt.event.ActionEvent evt) {
String data[][] = db.selectAll("tblBehemoth");
int selected = (int) cmbMothHead.getSelectedItem();
String HP = data[selected][2]; //First [] = Row number // Second [] = Col Name
System.out.println(HP);
}
所有数据都存储在数据库中,Hitpoints是列名