문제

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 !

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top