如果我想将 an 添加ArrayList
到 a JList
,它不会显示在列表中,但数组包含项目。我该如何解决这个问题?
public void updateLeftList(){
// Enter the search text
interFace.Search.setText(this.search);
// Get the left list
JList leftList = interFace.LeftList;
leftList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
// Define the arraylists
allPdf = new ArrayList();
curPdf = new ArrayList();
addPdf = new ArrayList();
// Get Files from manuals folder
File files = new File(configFile.getProperty("dir") + "/" + this.taal);
File[] listFiles = files.listFiles();
for(int i = 0; i < listFiles.length; i++){
if(listFiles[i].getName().endsWith(".pdf") && listFiles[i].isFile()){
allPdf.add(listFiles[i].getName().toString());
}
}
leftList.setListData(allPdf.toArray());
}