I have an JList
and I want to get the information of the Element.
This is my toString
output and I want to get the Element of Kundennummer.
Privatkunde [Vorname= Max| Nachname= Mustermann| Telefonnummer= 017632447658| E-Mail= musterman@max.de| Geburtsdatum= 08.03.1993| Kundennummer= KU543-10] Adresse [Adresszeile 1= Maxstraße, Adresszeile 2= 22, PLZ= 12139, Ort= Berlin]
That is my code how I want to proceed it but it does not work.
jL.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt){
if(evt.getClickCount()==2 && evt.getButton() == MouseEvent.BUTTON1){
int index = jL.locationToIndex(evt.getPoint());
String ausgewaehlteKdnr = model.getElementAt(index).substring(30,2);
System.out.println(ausgewaehlteKdnr);
jD.dispose();
}
}
});
It gives me the Error. I think that it just count from Privatkunde and finish but that is not what I want. I am glad if someone can say me how I fix it or a better way to get the information
java.lang.StringIndexOutOfBoundsException: String index out of range: -28