I have written a sample program that may help you to understand how to do that thing that you wanted to do. I have added a new JPanel layed out by a CardLayout to the center of the main frame and then used that panel to display different components depending on the current tree selection.
The core functionality of the sample program lies in the addComponent, and the valueChanged methods. Take a careful look at them.