[英]How to get the selected index number when multiple data in JList is selected
try{
f = new ProjectFile();
numProject = f.getOutput();
String[] projectData = new String[numProject.length];
//retrieving data from another file and store the title to projectData //从另一个文件检索数据并将标题存储到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){
}
use getSelectedIndices()
method 使用getSelectedIndices()
方法
public int[] getSelectedIndices()
Returns an array of all of the selected indices, in increasing order.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.