ArrayIndexOutOfBoundsException: -1 in jList
hey i have a jList in this i add elements from a database all, when i
create a new element in the database and press the button to get the new
element in the jList i get a IndexOutofBound BUT when i press again it
works ... Create new Element
try{
String date = jDateChooser1.getDate().toString();
String Termin = jTextArea1.getText();
System.out.println(date+"\n"+Termin);
sessionBean.createTermin(date, Termin);
}catch(NullPointerException npe){
JOptionPane.showMessageDialog(null, "Bitte Datum Auswählen");
}
Get the elements for tge jList
listModel.removeAllElements();
termin = sessionBean.getTermin();
datum = sessionBean.getDatum();
for (int i = 0 ; i < datum.size(); i++){
listModel.addElement(datum.get(i).toString());
}
and here the methode when i press at a element from the jList i get the
information
termin = sessionBean.getTermin();
index = jList1.getSelectedIndex();
if (!evt.getValueIsAdjusting()){
jTextArea2.setText(termin.get(index).toString());
}
No comments:
Post a Comment