Cannot reload jlist

I have made a file folder that shows the files list in the folder. After I select the folder, it will run the LoadFileList method and the list of files will be displayed in the JList called fileList.

privatevoid LoadFileList(String path){

String userDir = path;

File folder =new File(userDir);

Vector data =new Vector();

String[] children = folder.list();

if (children ==null){

// Either dir does not exist or is not a directory

}else{

for (int i=0; i<children.length; i++){

// Get filename of file or directory

String filename = children[i];

data.add(filename);

jLabel1.setText(filename);

}

// updateList(data);

fileList =new JList(data);

fileList.revalidate();

fileList.repaint();

}

}

However, the jlist cannot be updated after the folder is selected...I have tried many different method... but still not work..

please give me some advices to solve this.

Thank you.>

[1665 byte] By [MISa] at [2007-11-27 5:10:50]
# 1
You don't create a new JList. The object is just added to memory, its not displayed on the GUI.You need to create a new ListModel and then you use list.setModel(...) to update the existing JList that is visible on the GUI.
camickra at 2007-7-12 10:31:04 > top of Java-index,Desktop,Core GUI APIs...