I have one JSplitpane, on both left and right component of the same, I have added JPanel each i.e. on leftPanel and rightPanel.
On the leftPanel, I have added a Jtree, and on selection of leaf of that tree, I want to relatively paint the contents on rightPanel. This is not working, how do I achieve it ?
I am new to swings and don't know how do we clear all the component mounted on controller, in my case rightPanel.
here is what i have written in the jTree event listener..
tree.addTreeSelectionListener(new SelectionListener(){
@Override
public void valueChanged(TreeSelectionEvent se) {
JTree tree = (JTree) se.getSource();
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
String selectedNodeName = selectedNode.toString();
if (selectedNode.isLeaf()) {
if(selectedNodeName.equals("Gold")){
rightpanel.repaint();
System.out.println(selectedNodeName);
}
}
}
});
Kindly please provide suggestions.