How do I display a JComponent, such as a Box in multiple places. Should be simple, I thought; all Java variables are references, so just store it many times. Didn't work. It was created and added to one pane of a JTabbedPane. Then copied by an assignment statement to 2 different panes so that its contents, once created, would be visible on those other pages amidst various different stuff for reference purposes. Only the last place added had it visible. If I commented out the last place, then the next-to-last, and if that commented out, then the first. Weird, and it violates what I thought I knew, -- all Java variables are references.
I tried storing it in an Object, then recasting it back. No luck. Any Ideas?
Components can only have one parent container; each time you add a component to another container you remove it from the previous container. There is just one possibility - create multiple identical instances of the component.
With some components you can share a model (e.g. TreeModel with JTree, TableModel with JTable) or Actions (JMenuItem, JButton, JCheckBox), but that's about as far as you're going to get.
Thank you for the reply. Although I knew that, its significance to the issue was not apparent. I have created three separate components, so that each may be reparented upon copy. It works. Thanks again