我正在尝试这段代码(在 Netbeans 中),我总是得到一长串错误(这里只有第一行)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at FootballFrame.jComboBox1ActionPerformed(FootballFrame.java:64
at FootballFrame.access$000(FootballFrame.java:3)
at FootballFrame$1.actionPerformed(FootballFrame.java:29)
at javax.swing.JComboBox.fireActionEvent(JComboBox.java:1260)
at javax.swing.JComboBox.setSelectedItem(JComboBox.java:588)
at javax.swing.JComboBox.setSelectedIndex(JComboBox.java:624)
at Javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(BasicComboPopup.java:835)
...
代码如下:
private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt)
{
String support = (String)jComboBox1.getSelectedItem();
league.setLeagueName(support);
}
方法league.setLeagueName(String aName) 在外面完美地工作......我真的不明白