Modifier and Type | Field and Description |
---|---|
static java.awt.Insets |
INSETS_2
2 pixel inset
|
static java.awt.Insets |
INSETS_5
5 pixel inset
|
static int |
tmpAnchor
Set this to define your own anchor in the doLayout routines.
|
static int[] |
tmpColFills
Use this to define your own column fills (i.e., horizontal expansion
of the elements in the gribag).
|
static int |
tmpFill
Set this to define your own fill in the doLayout routines.
|
static java.awt.Insets |
tmpInsets
If you want to change the insets used in the doLayout routines
you can set this and the routine will use the value and then set it to null.
|
static double[] |
WT_N
doLayout weights
|
static double[] |
WT_NN
doLayout weights
|
static double[] |
WT_NNN
doLayout weights
|
static double[] |
WT_NNNY
doLayout weights
|
static double[] |
WT_NNY
doLayout weights
|
static double[] |
WT_NNYN
doLayout weights
|
static double[] |
WT_NNYNY
doLayout weights
|
static double[] |
WT_NNYNYNY
doLayout weights
|
static double[] |
WT_NY
doLayout weights
|
static double[] |
WT_NYN
doLayout weights
|
static double[] |
WT_NYNY
doLayout weights
|
static double[] |
WT_NYNYN
doLayout weights
|
static double[] |
WT_NYY
doLayout weights
|
static double[] |
WT_Y
All of the WT_ members are used to define the column and row
weights for the doLayout routines.
|
static double[] |
WT_YN
doLayout weights
|
static double[] |
WT_YNN
doLayout weights
|
static double[] |
WT_YNY
doLayout weights
|
static double[] |
WT_YNYN
doLayout weights
|
static double[] |
WT_YY
doLayout weights
|
static double[] |
WT_YYN
doLayout weights
|
static double[] |
WT_YYY
doLayout weights
|
static java.awt.Insets |
ZERO_INSETS
A 0 inset
|
MENU_SEPARATOR
Constructor and Description |
---|
LayoutUtil() |
Modifier and Type | Method and Description |
---|---|
static javax.swing.JPanel |
bottom(java.awt.Component bottom)
Creates a JPanel and does a BorderLayout SOUTH of the given component
|
static javax.swing.JPanel |
center(java.awt.Component center)
Creates a JPanel and does a BorderLayout CENTER of the given component
|
static javax.swing.JPanel |
centerBottom(java.awt.Component center,
java.awt.Component bottom)
Creates a JPanel and does a BorderLayout CENTER/SOUTH of the given components
|
static javax.swing.JPanel |
centerRight(java.awt.Component center,
java.awt.Component right)
Creates a JPanel and does a BorderLayout of the given components
|
static javax.swing.JPanel |
colGrid(java.awt.Component[] components,
int cols)
Do a grid layout with the number of columns
|
static javax.swing.JPanel |
doLayout(java.awt.Component[] components,
int numberOfColumns,
double[] weightsX,
double[] weightsY)
This does a column oriented grid bag layout.
|
static javax.swing.JPanel |
doLayout(javax.swing.JPanel parentContainer,
java.awt.Component[] components,
int numberOfColumns,
double[] weightsX,
double[] weightsY)
This does a column oriented grid bag layout.
|
static javax.swing.JPanel |
doLayout(javax.swing.JPanel parentContainer,
java.awt.Component[] components,
int numberOfColumns,
double[] weightsX,
double[] weightsY,
java.util.Hashtable anchors,
java.util.Hashtable fills,
java.awt.Insets insets)
This does a column oriented grid bag layout.
|
static javax.swing.JPanel |
doLayout(java.util.List components,
int numberOfColumns,
double[] weightsX,
double[] weightsY)
This does a column oriented grid bag layout.
|
static javax.swing.JPanel |
doLayout(java.util.List components,
int numberOfColumns,
int hinset,
int vinset)
This does a column oriented grid bag layout.
|
static java.awt.Component |
filler()
A utility for having fillers in layout.
|
static javax.swing.JComponent |
filler(int width,
int height)
A utility for having fillers in layout.
|
static java.awt.Component[] |
getComponentArray(java.util.List listOfComponents)
A utility to convert the listOfComponents into a Component array
|
static javax.swing.JPanel |
grid(java.awt.Component[] components,
int rows,
int cols)
Do a grid layout with the number of columns
|
static javax.swing.JPanel |
grid(java.awt.Component[] components,
int rows,
int cols,
int space)
Do a grid layout with the number of columns
|
static javax.swing.JPanel |
hbox(java.awt.Component[] components)
Do a horizontal layout of the given components.
|
static javax.swing.JPanel |
hbox(java.awt.Component[] components,
int spacing)
Do a horizontal layout of the given components.
|
static javax.swing.JPanel |
hbox(java.awt.Component c1,
java.awt.Component c2)
Do a horizontal layout of the given components.
|
static javax.swing.JPanel |
hbox(java.awt.Component c1,
java.awt.Component c2,
java.awt.Component c3)
Do a horizontal layout of the given components.
|
static javax.swing.JPanel |
hbox(java.awt.Component c1,
java.awt.Component c2,
java.awt.Component c3,
java.awt.Component c4)
Do a horizontal layout of the given components.
|
static javax.swing.JPanel |
hbox(java.awt.Component c1,
java.awt.Component c2,
java.awt.Component c3,
int spacing)
Do a horizontal layout of the given components with the given spacing.
|
static javax.swing.JPanel |
hbox(java.awt.Component c1,
java.awt.Component c2,
int spacing)
Do a horizontal layout of the given components with the given spacing.
|
static javax.swing.JPanel |
hbox(javax.swing.JPanel panel,
java.util.List components)
Do a horizontal layout of the given components.
|
static javax.swing.JPanel |
hbox(javax.swing.JPanel panel,
java.util.List components,
int space)
Do a horizontal layout of the given components.
|
static javax.swing.JPanel |
hbox(java.util.List components)
Do a horizontal layout of the given components.
|
static javax.swing.JPanel |
hbox(java.util.List components,
int spacing)
Do a horizontal layout of the given components.
|
static javax.swing.JComponent |
hfill(javax.swing.JComponent comp)
Wrap the component so that it only expands horizontally, not vertically
|
static javax.swing.JPanel |
hflow(java.util.List components)
Create a new JPanel and add the given components to it using
a FlowLayout.
|
static javax.swing.JPanel |
hflow(java.util.List components,
int hgap,
int vgap)
Create a new JPanel and add the given components to it using
a FlowLayout.
|
static javax.swing.JPanel |
hgrid(java.awt.Component comp1,
java.awt.Component comp2)
Do a horizontal grid layout of the given components
|
static javax.swing.JPanel |
hgrid(java.util.List components)
Do a horizontal grid layout of the given components
|
static javax.swing.JPanel |
hgrid(java.util.List components,
int space)
Do a horizontal grid layout of the given components
|
static javax.swing.JPanel |
inset(java.awt.Component c,
java.awt.Insets insets)
Inset the given component by the given insets.
|
static javax.swing.JPanel |
inset(java.awt.Component c,
int insetSize)
Inset the given component by the given insetSize, both
horizontally and vertically.
|
static javax.swing.JPanel |
inset(java.awt.Component c,
int insetSizeHor,
int insetSizeVert)
Inset the given component by the given insetSize for
horizontally and vertically.
|
static javax.swing.JPanel |
inset(javax.swing.JPanel parent,
java.awt.Component c,
int insetSize)
Inset the given component, adding it into the
given parent container, by the given insetSize, both
horizontally and vertically.
|
static javax.swing.JPanel |
left(java.awt.Component left)
Creates a JPanel and does a BorderLayout.WEST of the given component
|
static javax.swing.JPanel |
leftCenter(java.awt.Component left,
java.awt.Component center)
Creates a JPanel and does a BorderLayout of the given components
|
static javax.swing.JPanel |
leftCenterRight(java.awt.Component left,
java.awt.Component center,
java.awt.Component right)
Creates a JPanel and does a BorderLayout of the given components
|
static javax.swing.JPanel |
leftRight(java.awt.Component left,
java.awt.Component right)
Creates a JPanel and does a BorderLayout of the given components
|
static javax.swing.JPanel |
leftVbox(java.util.List components)
This places the given components in a vertical orientation, left aligned.
|
static javax.swing.JPanel |
right(java.awt.Component right)
Creates a JPanel and does a BorderLayout of the given components
|
static javax.swing.JPanel |
rowGrid(java.awt.Component[] components,
int rows)
Do a grid layout with the number of rows
|
static javax.swing.JPanel |
rowGrid(java.util.List comps,
int rows)
Do a grid layout with the number of rows
|
static void |
setAnchorBottom()
Sets the anchor to bottom for doLayout
|
static void |
setAnchorTop()
Sets the anchor to top for doLayout
|
static void |
setHFill()
Turns on component horizontal fill for the doLayout routine
|
static void |
setNoFill()
Turns off component fill for the doLayout routine
|
static java.util.List |
toList(java.lang.Object[] l) |
static javax.swing.JPanel |
top(java.awt.Component top)
Creates a JPanel and does a BorderLayout-NORTH of the given component
|
static javax.swing.JPanel |
topBottom(java.awt.Component top,
java.awt.Component bottom)
Creates a JPanel and does a BorderLayout NORTH/BOTTOM of the given components
|
static javax.swing.JPanel |
topCenter(java.awt.Component top,
java.awt.Component center)
Creates a JPanel and does a BorderLayout NORTH/CENTER of the given components
|
static javax.swing.JPanel |
topCenterBottom(java.awt.Component top,
java.awt.Component center,
java.awt.Component bottom)
Creates a JPanel and does a BorderLayout of the given components
|
static javax.swing.JPanel |
topLeft(java.awt.Component top)
Creates a JPanel and does a BorderLayout-NORTH of the given component
|
static javax.swing.JPanel |
vbox(java.awt.Component[] components)
Layout the given components vertically.
|
static javax.swing.JPanel |
vbox(java.awt.Component c1,
java.awt.Component c2)
Layout the given components vertically.
|
static javax.swing.JPanel |
vbox(java.awt.Component c1,
java.awt.Component c2,
java.awt.Component c3)
Layout the given components vertically.
|
static javax.swing.JPanel |
vbox(java.awt.Component c1,
java.awt.Component c2,
java.awt.Component c3,
java.awt.Component c4)
Layout the given components vertically.
|
static javax.swing.JPanel |
vbox(java.awt.Component c1,
java.awt.Component c2,
java.awt.Component c3,
java.awt.Component c4,
java.awt.Component c5)
Layout the given components vertically.
|
static javax.swing.JPanel |
vbox(javax.swing.JPanel panel,
java.util.List components)
Layout the given components vertically.
|
static javax.swing.JPanel |
vbox(java.util.List components)
Layout the given components vertically.
|
static javax.swing.JPanel |
vgrid(javax.swing.JPanel panel,
java.util.List components,
int space)
Do a single column grid layout of the components
|
static javax.swing.JPanel |
vgrid(java.util.List components)
Do a single column grid layout of the components
|
static javax.swing.JPanel |
wrap(java.awt.Component c)
Wrap the given component.
|
static javax.swing.JPanel |
wrapLeft(java.awt.Component c)
Wrap the given component, aligning it to the left.
|
findMethod, makeCheckboxMenuItem, makeCheckboxMenuItem, makeMenu, makeMenu, makeMenuItem, makeMenuItem, makeMenuItem, makeMenuItems, makePopupMenu, makePopupMenu, showPopupMenu, typesMatch
public static java.awt.Insets tmpInsets
public static final java.awt.Insets INSETS_5
public static final java.awt.Insets INSETS_2
public static int[] tmpColFills
public static int tmpAnchor
setAnchorBottom()
and setAnchorTop()
for
changing the anchor.public static int tmpFill
setNoFill()
and setHFill()
for doing
no fill and horizontal fill.public static final java.awt.Insets ZERO_INSETS
public static final double[] WT_Y
So for example, if you wanted to have no stretchiness in the first column and put all of the stretchiness into the second column you would use:
WT_NY
Note, you can pass in your own double arrays to doLayout. These are just here for convenience.
public static final double[] WT_YY
public static final double[] WT_YYY
public static final double[] WT_N
public static final double[] WT_NN
public static final double[] WT_NNN
public static final double[] WT_YN
public static final double[] WT_YYN
public static final double[] WT_YNYN
public static final double[] WT_NYNYN
public static final double[] WT_NY
public static final double[] WT_NYN
public static final double[] WT_YNY
public static final double[] WT_NYY
public static final double[] WT_YNN
public static final double[] WT_NNY
public static final double[] WT_NNNY
public static final double[] WT_NNYN
public static final double[] WT_NNYNY
public static final double[] WT_NNYNYNY
public static final double[] WT_NYNY
public static void setNoFill()
public static javax.swing.JComponent hfill(javax.swing.JComponent comp)
comp
- The componentpublic static void setHFill()
public static void setAnchorBottom()
public static void setAnchorTop()
public static javax.swing.JPanel inset(java.awt.Component c, int insetSize)
c
- The component to wrapinsetSize
- Horizontal and vertical insetpublic static javax.swing.JPanel inset(java.awt.Component c, int insetSizeHor, int insetSizeVert)
c
- The component to wrapinsetSizeHor
- Inset horizontalinsetSizeVert
- Inset verticalpublic static javax.swing.JPanel inset(java.awt.Component c, java.awt.Insets insets)
c
- The component to wrapinsets
- The insetspublic static javax.swing.JPanel wrapLeft(java.awt.Component c)
c
- The component to wrappublic static javax.swing.JPanel wrap(java.awt.Component c)
c
- The component to wrappublic static javax.swing.JPanel hflow(java.util.List components)
components
- The components to layoutpublic static javax.swing.JPanel hflow(java.util.List components, int hgap, int vgap)
components
- The components to layouthgap
- Horizontal spacingvgap
- Vertical spacingpublic static javax.swing.JPanel hgrid(java.awt.Component comp1, java.awt.Component comp2)
comp1
- comp1comp2
- comp2_public static javax.swing.JPanel hgrid(java.util.List components)
components
- The components to layoutpublic static javax.swing.JPanel hgrid(java.util.List components, int space)
components
- The components to layoutspace
- The spacingpublic static javax.swing.JPanel vgrid(java.util.List components)
components
- The components to layoutpublic static javax.swing.JPanel vgrid(javax.swing.JPanel panel, java.util.List components, int space)
panel
- The panel to add tocomponents
- The components to layoutspace
- The spacingpublic static javax.swing.JPanel rowGrid(java.util.List comps, int rows)
comps
- Components to layoutrows
- Number of rowspublic static javax.swing.JPanel rowGrid(java.awt.Component[] components, int rows)
components
- Components to layoutrows
- Number of rowspublic static javax.swing.JPanel colGrid(java.awt.Component[] components, int cols)
components
- Components to layoutcols
- Number of colspublic static javax.swing.JPanel grid(java.awt.Component[] components, int rows, int cols)
components
- Components to layoutrows
- Number of rows (0 implies not fixed)cols
- Number of cols (0 implies not fixed)public static javax.swing.JPanel grid(java.awt.Component[] components, int rows, int cols, int space)
components
- Components to layoutrows
- Number of rows (0 implies not fixed)cols
- Number of cols (0 implies not fixed)space
- Spacingpublic static javax.swing.JPanel inset(javax.swing.JPanel parent, java.awt.Component c, int insetSize)
parent
- The panel to put the component in.c
- The component to wrapinsetSize
- Horizontal and vertical insetpublic static javax.swing.JPanel doLayout(java.util.List components, int numberOfColumns, int hinset, int vinset)
components
- List of Component
s to layoutnumberOfColumns
- How many columns in the grid layouthinset
- hor. insetvinset
- vert. insetpublic static java.awt.Component[] getComponentArray(java.util.List listOfComponents)
listOfComponents
- List of Componentspublic static javax.swing.JPanel doLayout(java.util.List components, int numberOfColumns, double[] weightsX, double[] weightsY)
components
- The components to layoutnumberOfColumns
- How many columns in the grid layoutweightsX
- Defines how much weight to give to each column width. If there are more
columns than weights then we use the last weight.weightsY
- Defines how much weight to give to each row height. If there are more
rows than weights then we use the last weight.public static javax.swing.JPanel doLayout(java.awt.Component[] components, int numberOfColumns, double[] weightsX, double[] weightsY)
components
- The components to layoutnumberOfColumns
- How many columns in the grid layoutweightsX
- Defines how much weight to give to each column width. If there are more
columns than weights then we use the last weight.weightsY
- Defines how much weight to give to each row height. If there are more
rows than weights then we use the last weight.public static javax.swing.JPanel doLayout(javax.swing.JPanel parentContainer, java.awt.Component[] components, int numberOfColumns, double[] weightsX, double[] weightsY)
parentContainer
- The container to add components to. May be null.components
- The components to layoutnumberOfColumns
- How many columns in the grid layoutweightsX
- Defines how much weight to give to each column width. If there are more
columns than weights then we use the last weight.weightsY
- Defines how much weight to give to each row height. If there are more
rows than weights then we use the last weight.public static javax.swing.JPanel vbox(java.awt.Component c1, java.awt.Component c2)
c1
- Component 1c2
- Component 2public static javax.swing.JPanel vbox(java.awt.Component c1, java.awt.Component c2, java.awt.Component c3)
c1
- Component 1c2
- Component 2c3
- Component 3public static javax.swing.JPanel vbox(java.awt.Component c1, java.awt.Component c2, java.awt.Component c3, java.awt.Component c4)
c1
- Component 1c2
- Component 2c3
- Component 3c4
- Component 4public static javax.swing.JPanel vbox(java.awt.Component c1, java.awt.Component c2, java.awt.Component c3, java.awt.Component c4, java.awt.Component c5)
c1
- Component 1c2
- Component 2c3
- Component 3c4
- Component 4public static javax.swing.JPanel vbox(java.awt.Component[] components)
components
- The componentspublic static java.util.List toList(java.lang.Object[] l)
public static javax.swing.JPanel vbox(java.util.List components)
components
- The componentspublic static javax.swing.JPanel vbox(javax.swing.JPanel panel, java.util.List components)
components
- The componentspanel
- The panel to put the components in if on-null.public static javax.swing.JPanel leftVbox(java.util.List components)
components
- The componentspublic static javax.swing.JPanel hbox(java.awt.Component c1, java.awt.Component c2, int spacing)
c1
- Component 1c2
- Component 2spacing
- Inter component spacingpublic static javax.swing.JPanel hbox(java.awt.Component c1, java.awt.Component c2, java.awt.Component c3, int spacing)
c1
- Component 1c2
- Component 2c3
- Component 3spacing
- Inter component spacingpublic static javax.swing.JPanel hbox(java.awt.Component c1, java.awt.Component c2)
c1
- Component 1c2
- Component 2public static javax.swing.JPanel hbox(java.awt.Component c1, java.awt.Component c2, java.awt.Component c3)
c1
- Component 1c2
- Component 2c3
- Component 3public static javax.swing.JPanel hbox(java.awt.Component c1, java.awt.Component c2, java.awt.Component c3, java.awt.Component c4)
c1
- Component 1c2
- Component 2c3
- Component 3c4
- Component 4public static javax.swing.JPanel hbox(java.util.List components, int spacing)
components
- The componentsspacing
- The spacingpublic static javax.swing.JPanel hbox(java.util.List components)
components
- The componentspublic static javax.swing.JPanel hbox(java.awt.Component[] components)
components
- The componentspublic static javax.swing.JPanel hbox(java.awt.Component[] components, int spacing)
components
- The componentsspacing
- _more_public static javax.swing.JPanel hbox(javax.swing.JPanel panel, java.util.List components)
panel
- The panel to use or, if null, we'll create a new on.components
- The componentspublic static javax.swing.JPanel hbox(javax.swing.JPanel panel, java.util.List components, int space)
panel
- The panel to use or, if null, we'll create a new on.components
- The componentsspace
- SPacing to usepublic static javax.swing.JPanel doLayout(javax.swing.JPanel parentContainer, java.awt.Component[] components, int numberOfColumns, double[] weightsX, double[] weightsY, java.util.Hashtable anchors, java.util.Hashtable fills, java.awt.Insets insets)
The weights define how much weight or spacing to give to the width of each column and the height of each row.
To define the anchor value, i.e., how to fill a component in its grid square,
you can either set the global static member tmpAnchor
or, for individual
Components you can use the anchors table to provide a mapping from Component to an
Integer object holding the anchor value.
To define the fill value, i.e., how a component expands in its grid square,
you can either set the global static member tmpFill
or, for individual
Components you can use the fills table to provide a mapping from Component to an
Integer object holding the fill value.
If insets is non-null it will use those insets for the spacing in the grid. else if the static member tmpInsets is non-null then it will use those values and then set tmpInsets to null. Else it uses DFLT_INSETS, which is 0 spacing.
parentContainer
- The container to add components to. May be null.components
- The components to layoutnumberOfColumns
- How many columns in the grid layoutweightsX
- Defines how much weight to give to each column width. If there are more
columns than weights then we use the last weight.weightsY
- Defines how much weight to give to each row height. If there are more
rows than weights then we use the last weight.anchors
- Hashtable that maps Component to the Integer which defines the component anchorfills
- Hashtable that maps Component to the Integer which defines the component fillinsets
- The insets to use in the gridpublic static javax.swing.JPanel topLeft(java.awt.Component top)
top
- The component to placepublic static javax.swing.JPanel top(java.awt.Component top)
top
- The component to placepublic static javax.swing.JPanel left(java.awt.Component left)
left
- The component to placepublic static javax.swing.JPanel topCenter(java.awt.Component top, java.awt.Component center)
top
- The top componentcenter
- The center componentpublic static javax.swing.JPanel topBottom(java.awt.Component top, java.awt.Component bottom)
top
- The top componentbottom
- The bottom componentpublic static javax.swing.JPanel centerBottom(java.awt.Component center, java.awt.Component bottom)
center
- The center componentbottom
- The bottom componentpublic static javax.swing.JPanel bottom(java.awt.Component bottom)
bottom
- The bottom componentpublic static javax.swing.JPanel center(java.awt.Component center)
center
- The center componentpublic static javax.swing.JPanel topCenterBottom(java.awt.Component top, java.awt.Component center, java.awt.Component bottom)
top
- The top component (may be null)center
- The center component (may be null)bottom
- The bottom component (may be null)public static javax.swing.JPanel leftRight(java.awt.Component left, java.awt.Component right)
left
- The left componentright
- The right componentpublic static javax.swing.JPanel leftCenterRight(java.awt.Component left, java.awt.Component center, java.awt.Component right)
left
- The left componentcenter
- The center componentright
- The right componentpublic static javax.swing.JPanel centerRight(java.awt.Component center, java.awt.Component right)
center
- The center componentright
- The right componentpublic static javax.swing.JPanel right(java.awt.Component right)
right
- The right componentpublic static javax.swing.JPanel leftCenter(java.awt.Component left, java.awt.Component center)
left
- The left componentcenter
- The center componentpublic static java.awt.Component filler()
public static javax.swing.JComponent filler(int width, int height)
width
- filler widthheight
- filler height