Unable to refresh the JList
Hi,
I facing the problem which unable to refresh the JList.
I have a splitPane where the first pane is a JTree and the second pane is to display the child of the JTree in JList which user click on.
For the first time the page is view, a list of default child(image, name) is displayed in JList at second pane. After user click on the folder in the JTree, The JList will be update to view the child for the selected tree's child.
The problem is, i was unable to update the JList at all.
Below is part of my code :-
Default JList for the first time the applet is view
childNod =new ChildNod[2];
childNod[0] =new ChildNod("Parent 4","little_bug_red.gif");
childNod[1] =new ChildNod("Parent 5","little_bug_red.gif");
listSelectedTreeChild =new JList(childNod);
listSelectedTreeChild.setCellRenderer(new ListChildRenderer());
JList after user click on the node in JTree
// Declare size for array and add element into ChildNod
childNod =new ChildNod[2];
childNod[0] =new ChildNod("Parent 7","little_bug_red.gif");
childNod[1] =new ChildNod("Parent 8","little_bug_red.gif");
listSelectedTreeChild =new JList(childNod);
listSelectedTreeChild.setCellRenderer(new ListChildRenderer());
listSelectedTreeChild.revalidate();
listSelectedTreeChild.repaint();
i even try to repaint the JSplitPane but it also doesn't work.
Below is the class for ChildNod:
publicclass ChildNod{
private String title;
private String imagePath;
private ImageIcon imageIcon;
public ChildNod(String title, String imagePath){
this.title = title;
this.imagePath = imagePath;
}
public String getTitle(){
return this.title;
}
public ImageIcon getImage(){
if (imagePath !=null){
imageIcon =new ImageIcon(imagePath);
}
return imageIcon;
}
public String toString(){
return title;
}
}
I had search through the forum, and i had try by using the "DefaultListModel" but it still doesn't work.

