Download presentation
Presentation is loading. Please wait.
Published byPatience Glenn Modified over 8 years ago
1
Grid Bag Layout Most Complex and Powerful Components can vary in size and can be added in any order Draw out on piece of paper first Columns and Rows: Components placed in a grid, and preferred sized used to determine how big Grig Bag Constraints determine how the object is placed in the layout
2
Grid Bag Constraints gridx : the column in which the component is placed (start at 0) gridy : the row in which the column is placed (start at 0) gridwidth : the number of columns the component occupies gridheight : the number of rows the component occupies
3
weightx : Portion of extra space in x when available (resize, 0-1). When space available, grows wider. 0 means doesn’t grow. weighty : Portion of extra space in y when available (resize, 0-1) When space available, grows taller. 0 means doesn’t grow. fill: How much of components area is occupied. –NONE:component will not grow –BOTH: component grows in both directions. –HORIZONTAL –VERTICAL
4
fill Used when the component's display area is larger than the component's requested size to determine whether and how to resize the component. Valid values are GridBagConstraints. NONE (the default), GridBagConstraints.HORIZONTAL (make the component wide enough to fill its display area horizontally, but don't change its height), GridBagConstraints. VERTICAL (make the component tall enough to fill its display area vertically, but don't change its width), and GridBagConstraints.BOTH (make the component fill its display area entirely).
5
Variation Don’t use gridx and gridy REMAINDER : Last component in the row RELATIVE : Next to last component in the row
11
Example Program
12
No fill set
13
No weightx set
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.