• Post Reply Bookmark Topic Watch Topic
  • New Topic

layout manager

 
toor toor
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When we change the size of window how layout updates.Explain in detail
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That depends on the layout manager. A FlowLayout acts like a static HTML page or "flowing" from left to right until there is no horizontal space left and then starts a new row. A GridLayout equally distributes the added space to each grid in the layout. A BorderLayout will add new horizontal space to the North, South and Center components and new vertical space to the East, West and Center components. A GridBagLayout depends on a lot of different factors, but gives you greatest control over the position of your components.
Michael Morris
 
Dorothy Finkel-Laverty
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The layout managers first have to calculate the "preferred size" of each component that goes into the container, so it depends on which layout manager you're using how that is done. Since FlowLayout is probably the one that does the most work in this matter, I'll talk about how FlowLayout handles this.
First, it caluclates the preferred size of each and every component, taking into account all of the fonts, initial text values, and other parameters that might affect the size.
Next, it adds in the horizontal and vertical spacing that you might have specified, or uses the default.
It adds up all of these requirements, and figures out how much space it needs. The pack() method of the container actually does all of these thing.
Hope this helps.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!