Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Don't automatically resize panel

 
M Bryan
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20510
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
M Bryan
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that did it, than you
 
Rob Spoor
Sheriff
Pie
Posts: 20510
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic