Layout Managers Flashcards
BorderLayout is default for…
Content pane of JFrame, JDialog and JApplet
BorderLayout
Seperates window into different sections
BorderLayout areas
North, South, East, West, Center
North
PAGE-START
South
PAGE_END
East
LINE_END
West
LINE_START
Center
CENTER
BoxLayout
Puts components in single row or column
BoxLayout Formatting Options
Respects components max sizes
Lets you align components
CardLayout
Lets you implement an area that contains different components at different times
CardLayout Controlled By
Controlled by combo box w/ state of combo box determining which panel (group of components) to display
CardLayout Alternative
Using a tabbed pane provides similar functionality but with a pre-defined GUI
FlowLayout
Lays out components in a single row
Starts new row if container is not wide enough
FlowLayout Default
Default for javax.swing.JPanel
GridBagLayout
Flexible and complex
Places components in grid of rows/columns and allows for specified components to span multiple rows or columns
Used components preferred size to determine cell size
GridBagConstrains
Constraints for each components is the way the program specifies the size and position characteristics of its components
GridBagConstrains Code
GridBagConstraints.add
Pass it GridBagConstraints object
GridBagConstrains
Gridx
Specifies cell containing leading edge of display area
First cell in row has gridx=0
GridBagConstrains
Gridy
Specifies cell at top of components display area
Topmost cell has gridy=0
GridBagConstrains
Gridwidth
Specifies number of cells in a row for the components display area
GridBagConstrains
Gridheight
Specifies number of cells in a column for the components display area
GridBagConstrains
Weightx
Specifies how to distribute extra horizontal space
GridBagConstrains
Weighty
Specifies how to distribute extra vertical weight
GridBagConstrains
Instance Variables
anchor
Field is used when component is smaller than display area
GridBagConstrains
Instance Variables
fill
Field is used when components display area is larger than the components requested size
GridBagConstrains
Instance Variables
insets
Specifies external padding of component
GridBagConstrains
Instance Variables
ipadx
Specifies internal padding of component as to width
GridBagConstrains
Instance Variables
ipady
Specifies internal padding as to height
GridLayout
Arranges components into rows and columns
Components equal in size
GroupLayout
Works with horizontal and vertical layouts separately; layout is defined for each dimension independently
Each components needs to be defined twice in the layout
SpringLayout
Specifies precise relationships between edges of components under its control
Lays out children of associated container according to constraints
Layout managers used by GUI builders
SpringLayout
GroupLayout