JPanel remove does not work
Hi!
I'm creating an interface which content is created dynamically. I have a JInternalFrame divided in two by a jsplitpane, in which on the left there is a Jtree and on the right I have a JPanel which content i need to be dynamically created depending on the JTree node selected.
I have tried with remove, revalidate/validate, add, validate, repaint but it seems not to work: the old button still remain and the others are painted over the old ones.
I didn't try the CardLayout, as someone suggested in this forum, because I have too many "cards" to create, and it will cost too much ram!
I post here the portion of the code where I try to create the new content:
EventQueue.invokeLater(new Runnable(){
publicvoid run(){
/*for (int i=nodePane.getComponentCount()-1; i>=0; i--)
nodePane.remove(i);*/
nodePane.removeAll();
nodePane.revalidate();
nodePane.setLayout(new SpringLayout());
//nodePane.add(title);
nodePane.add(new JButton(currNode.toString()));
SpringUtilities.makeCompactGrid(nodePane,
2 , 1,//rows, cols
6, 6,//initX, initY
6, 6);//xPad, yPad
nodePane.repaint();
nodePane.revalidate();
}
});
Help me please!!!

