Start New Discussion within our Software Development Community

Hi, I have really weird layout problem.

I have a class VerticalGridPanel, which uses GridBagLayout to place components top to bottom, left to right, nothing special.

Then I have a List of components, which i want to add a part of to a VerticalGridPanel. I then want to add another part of the same list to another VerticalGridPanel, the VerticalGridPanels stores many of the same components from the list.

Now the problem is that if I add Components 0-10 from the list to a VerticalGridPanel and then add Component 5-15 to another VerticalGridPanel, then components 5-10 dissapeares from the first VerticalGridPanel. I of course want the panels to show the duplicates as I would expect.

I also noted that when i call getComponentCount on the first panel directly after populating it I get the right amount of components. But when I add components to the second panel the first panel loses exactly as many components as there were duplicates in the second panel.

This is to me very strange behaviour, and I cant seem find out what the problem is. Are you not supposed to add the same components to different panels?

The code is pretty simple and i dont think it would do much to post it, but just write if you feel it's needed.

Okay it seems like a components can only have one parent, so thats that, solved it in another way.

Thank you

youre welcome

This question has already been answered. Start a new discussion instead.