aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Don't automatically resize panel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Don Watch "Don New topic
Author

Don't automatically resize panel

M Bryan
Ranch Hand

Joined: Jun 15, 2011
Posts: 64
Hi,

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?

thank you in advance
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19719
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
M Bryan
Ranch Hand

Joined: Jun 15, 2011
Posts: 64
that did it, than you
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19719
    
  20

You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Don't automatically resize panel