C
christopher_board
Hi all,
I am currently developing a java application that has a combo box and
a list box. I have a menu options which is called Locate Data File.
When I click on this menu item it is supposed to clear the data from
the list box and from the combo box and then load a dialogue box.
However what it is doing is, when I click the menu the program crashes
and comes up with an error saying:
Exception in thread "AWT-EventQueue-0"
java.lang.NullPointerException.
However the combo box and the JList clears the data out if it. When i
then click the menu again the program works without coming up with the
error.
When I have debugged the program it is falling over around the part
where it is clearing the combo box. Below is the code that I am using:
public void jMenuOptionsLocateDataFile_actionPerformed(ActionEvent
e) {
cboRoomNumber.removeAllItems();
lstComputerNames.getModel();
data.removeAllElements();
lstComputerNames.removeAll();
DataFile dlg = new DataFile(this);
Dimension dlgSize = dlg.getPreferredSize();
Dimension frmSize = getSize();
Point loc = getLocation();
dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
(frmSize.height - dlgSize.height) / 2 +
loc.y);
dlg.setModal(true);
dlg.pack();
dlg.setVisible(true);
}
Where it says cboRoomNumber.removeAllItems(); this is where it is
supposed to clear the combo box but it seems to be falling over at
this point.
Any help in this matter would be highly appreciated.
Thank you
I am currently developing a java application that has a combo box and
a list box. I have a menu options which is called Locate Data File.
When I click on this menu item it is supposed to clear the data from
the list box and from the combo box and then load a dialogue box.
However what it is doing is, when I click the menu the program crashes
and comes up with an error saying:
Exception in thread "AWT-EventQueue-0"
java.lang.NullPointerException.
However the combo box and the JList clears the data out if it. When i
then click the menu again the program works without coming up with the
error.
When I have debugged the program it is falling over around the part
where it is clearing the combo box. Below is the code that I am using:
public void jMenuOptionsLocateDataFile_actionPerformed(ActionEvent
e) {
cboRoomNumber.removeAllItems();
lstComputerNames.getModel();
data.removeAllElements();
lstComputerNames.removeAll();
DataFile dlg = new DataFile(this);
Dimension dlgSize = dlg.getPreferredSize();
Dimension frmSize = getSize();
Point loc = getLocation();
dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
(frmSize.height - dlgSize.height) / 2 +
loc.y);
dlg.setModal(true);
dlg.pack();
dlg.setVisible(true);
}
Where it says cboRoomNumber.removeAllItems(); this is where it is
supposed to clear the combo box but it seems to be falling over at
this point.
Any help in this matter would be highly appreciated.
Thank you