I have a JList with some items. I've added a listener for when a item in the list is selected. Here is the code for what happens when an item in the list is selected:
private void questionaireNamesListValueChanged(javax.swing.event.ListSelectionEvent evt) {
try {
inputPanel.setEnabled(false);
inputPanel.setVisible(false);
inputTextField.setText("");
inputStatusLabel.setText("");
// get the questionaireIndex selected
int questionaireIndex = questionaireNamesList.getSelectedIndex();
**System.out.println("Questionaire Index: " + questionaireIndex);**
// check if that questionaire has five questions
if (remoteQuestionServer.getQuestionCount(questionaireIndex) == 5) {
answerQuestionButton.setEnabled(true);
addQuestionButton.setEnabled(false);
} else {
addQuestionButton.setEnabled(true);
answerQuestionButton.setEnabled(false);
}
} catch (RemoteException ex) {
ex.printStackTrace();
}
}
As you can above I put a System.out.print statement in and every time I click on something in the list I get two ouputs for that item, eg.
Questionaire Index: 4
Questionaire Index: 4
Questionaire Index: 2
Questionaire Index: 2
Questionaire Index: 0
Questionaire Index: 0
Questionaire Index: 2
Questionaire Index: 2
Any idea why this is happening?
Thanks, Patrick