如何删除JList中的多个项目

Vex*_*toR 4 java swing netbeans jlist

这很有趣,我无法找到如何删除JList中的多个选定项目

请帮忙

在此输入图像描述

UPD: 好的,问题出在NetBeans中,因为它创建了JList并设置了AbstractListModel某种模式,而这种模型在某种程度上与remove方法无关.

Vex*_*toR 15

   DefaultListModel dlm = (DefaultListModel) subjectList.getModel();

      if(this.subjectList.getSelectedIndices().length > 0) {
          int[] selectedIndices = subjectList.getSelectedIndices();
          for (int i = selectedIndices.length-1; i >=0; i--) {
              dlm.removeElementAt(selectedIndices[i]);
          } 
    } 
Run Code Online (Sandbox Code Playgroud)