This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
i have written an own layout manager for my use case. i have a panel with boxes, which can be moved through the panel, they can be ordered next to each other, above and below each other an in the corners. when a new box enters the field and it is to big, all existing boxes resizes themselves a bit, so that the new friend fits in the panel.
but i have a problem: java sets the size of the main panel on it's own.
for example: the height of the panel is 1000px (let's say that's the size of screen). when there is one box with 600px, everythings fine. when next to the box comes another box with also 600px, java resizes the panel to 1200px, although the two boxes are next to each other and the 200 additional pixels are not needed.
how can i tell java not to resize the mainpanel until the additional space is really needed?
The layout manager determines how large the panel should be, so I'd check your implementation for preferredLayoutSize. If two components will be located next to each other the height for the panel should be the max of the two component heights, not the sum.