Removing items from JList

前端 未结 6 1106
野性不改
野性不改 2021-01-01 05:26

I\'ve got a simple Jlist with data from List, Now I want to remove selected item from Jlist. Here is the code:

final DefaultListMo         


        
6条回答
  •  臣服心动
    2021-01-01 05:51

    Assuming your index is non-negative (as mentioned by others), see if this works (in your listener):

    ((DefaultListModel) jList.getModel()).remove(index);
    

    If so, then you're using using a stale model.

提交回复
热议问题