Thursday, November 23, 2006

Moving components from one container to an other container

I had some trouble moving a component from a JPanel with CardLayout to another container (e.g. JSplitPane) to view two panels at the same time. The moved panels were not shown in the new container.
The trick was that the CardLayout made the components invisible. So if you want to get shown them in the new container you have to make sure they are visbile by setVisible(true).

search hints: moving, removing, adding, load, unload, CardLayout, JPanel, JSplitPane