I have no idea why it's happening, I'll look at other parts of my code if I need to but I really prefer it to be something else...
let's say I have the following items in my JList
Beer
Mercedes
Coca Cola
and str == "Mercedes", it will remove everything but this item.
why?
for(int i=0;i<listModel.getSize();i++){
if (listModel.elementAt(i).equals(str))
listModel.remove(i);
}
You could try that :
listModel.removeElement(str)
And don't forget to check Strings for null values !
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.