【问题标题】:How to get the selected index number when multiple data in JList is selected选择JList中的多个数据时如何获取选择的索引号
【发布时间】:2012-07-14 07:20:09
【问题描述】:
    try{
    f = new ProjectFile();

    numProject = f.getOutput();

    String[] projectData = new String[numProject.length];

//从另一个文件中检索数据并将标题存储到projectData

        for (int i = 0; i < projectData.length; i++) {
            projectData[i] = numProject[i].getProjectTitle();
        }

        listProject.setListData(projectData);
        System.out.println(listProject.getSelectedIndex());
}catch(Exception e){
}

【问题讨论】:

    标签: java swing return jlist


    【解决方案1】:

    使用getSelectedIndices()方法

    public int[] getSelectedIndices()
    
    Returns an array of all of the selected indices, in increasing order. 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-12
      • 2011-09-08
      • 1970-01-01
      • 1970-01-01
      • 2011-02-01
      • 2013-12-13
      相关资源
      最近更新 更多