|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectucar.unidata.util.MenuUtil
ucar.unidata.util.LayoutUtil
public class LayoutUtil
This is a vast catchall class to old various utilities for doing GUI things.
| Field Summary | |
|---|---|
static Insets |
INSETS_2
2 pixel inset |
static 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 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 Insets |
ZERO_INSETS
A 0 inset |
| Fields inherited from class ucar.unidata.util.MenuUtil |
|---|
MENU_SEPARATOR |
| Constructor Summary | |
|---|---|
LayoutUtil()
|
|
| Method Summary | |
|---|---|
static JPanel |
bottom(Component bottom)
Creates a JPanel and does a BorderLayout SOUTH of the given component |
static JPanel |
center(Component center)
Creates a JPanel and does a BorderLayout CENTER of the given component |
static JPanel |
centerBottom(Component center,
Component bottom)
Creates a JPanel and does a BorderLayout CENTER/SOUTH of the given components |
static JPanel |
centerRight(Component center,
Component right)
Creates a JPanel and does a BorderLayout of the given components |
static JPanel |
colGrid(Component[] components,
int cols)
Do a grid layout with the number of columns |
static JPanel |
doLayout(Component[] components,
int numberOfColumns,
double[] weightsX,
double[] weightsY)
This does a column oriented grid bag layout. |
static JPanel |
doLayout(JPanel parentContainer,
Component[] components,
int numberOfColumns,
double[] weightsX,
double[] weightsY)
This does a column oriented grid bag layout. |
static JPanel |
doLayout(JPanel parentContainer,
Component[] components,
int numberOfColumns,
double[] weightsX,
double[] weightsY,
Hashtable anchors,
Hashtable fills,
Insets insets)
This does a column oriented grid bag layout. |
static JPanel |
doLayout(List components,
int numberOfColumns,
double[] weightsX,
double[] weightsY)
This does a column oriented grid bag layout. |
static JPanel |
doLayout(List components,
int numberOfColumns,
int hinset,
int vinset)
This does a column oriented grid bag layout. |
static Component |
filler()
A utility for having fillers in layout. |
static JComponent |
filler(int width,
int height)
A utility for having fillers in layout. |
static Component[] |
getComponentArray(List listOfComponents)
A utility to convert the listOfComponents into a Component array |
static JPanel |
grid(Component[] components,
int rows,
int cols)
Do a grid layout with the number of columns |
static JPanel |
grid(Component[] components,
int rows,
int cols,
int space)
Do a grid layout with the number of columns |
static JPanel |
hbox(Component[] components)
Do a horizontal layout of the given components. |
static JPanel |
hbox(Component[] components,
int spacing)
Do a horizontal layout of the given components. |
static JPanel |
hbox(Component c1,
Component c2)
Do a horizontal layout of the given components. |
static JPanel |
hbox(Component c1,
Component c2,
Component c3)
Do a horizontal layout of the given components. |
static JPanel |
hbox(Component c1,
Component c2,
Component c3,
Component c4)
Do a horizontal layout of the given components. |
static JPanel |
hbox(Component c1,
Component c2,
Component c3,
int spacing)
Do a horizontal layout of the given components with the given spacing. |
static JPanel |
hbox(Component c1,
Component c2,
int spacing)
Do a horizontal layout of the given components with the given spacing. |
static JPanel |
hbox(JPanel panel,
List components)
Do a horizontal layout of the given components. |
static JPanel |
hbox(JPanel panel,
List components,
int space)
Do a horizontal layout of the given components. |
static JPanel |
hbox(List components)
Do a horizontal layout of the given components. |
static JPanel |
hbox(List components,
int spacing)
Do a horizontal layout of the given components. |
static JComponent |
hfill(JComponent comp)
Wrap the component so that it only expands horizontally, not vertically |
static JPanel |
hflow(List components)
Create a new JPanel and add the given components to it using a FlowLayout. |
static JPanel |
hflow(List components,
int hgap,
int vgap)
Create a new JPanel and add the given components to it using a FlowLayout. |
static JPanel |
hgrid(Component comp1,
Component comp2)
Do a horizontal grid layout of the given components |
static JPanel |
hgrid(List components)
Do a horizontal grid layout of the given components |
static JPanel |
hgrid(List components,
int space)
Do a horizontal grid layout of the given components |
static JPanel |
inset(Component c,
Insets insets)
Inset the given component by the given insets. |
static JPanel |
inset(Component c,
int insetSize)
Inset the given component by the given insetSize, both horizontally and vertically. |
static JPanel |
inset(Component c,
int insetSizeHor,
int insetSizeVert)
Inset the given component by the given insetSize for horizontally and vertically. |
static JPanel |
inset(JPanel parent,
Component c,
int insetSize)
Inset the given component, adding it into the given parent container, by the given insetSize, both horizontally and vertically. |
static JPanel |
left(Component left)
Creates a JPanel and does a BorderLayout.WEST of the given component |
static JPanel |
leftCenter(Component left,
Component center)
Creates a JPanel and does a BorderLayout of the given components |
static JPanel |
leftCenterRight(Component left,
Component center,
Component right)
Creates a JPanel and does a BorderLayout of the given components |
static JPanel |
leftRight(Component left,
Component right)
Creates a JPanel and does a BorderLayout of the given components |
static JPanel |
leftVbox(List components)
This places the given components in a vertical orientation, left aligned. |
static JPanel |
right(Component right)
Creates a JPanel and does a BorderLayout of the given components |
static JPanel |
rowGrid(Component[] components,
int rows)
Do a grid layout with the number of rows |
static JPanel |
rowGrid(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 List |
toList(Object[] l)
|
static JPanel |
top(Component top)
Creates a JPanel and does a BorderLayout-NORTH of the given component |
static JPanel |
topCenter(Component top,
Component center)
Creates a JPanel and does a BorderLayout NORTH/CENTER of the given components |
static JPanel |
topCenterBottom(Component top,
Component center,
Component bottom)
Creates a JPanel and does a BorderLayout of the given components |
static JPanel |
topLeft(Component top)
Creates a JPanel and does a BorderLayout-NORTH of the given component |
static JPanel |
vbox(Component[] components)
Layout the given components vertically. |
static JPanel |
vbox(Component c1,
Component c2)
Layout the given components vertically. |
static JPanel |
vbox(Component c1,
Component c2,
Component c3)
Layout the given components vertically. |
static JPanel |
vbox(Component c1,
Component c2,
Component c3,
Component c4)
Layout the given components vertically. |
static JPanel |
vbox(JPanel panel,
List components)
Layout the given components vertically. |
static JPanel |
vbox(List components)
Layout the given components vertically. |
static JPanel |
vgrid(JPanel panel,
List components,
int space)
Do a single column grid layout of the components |
static JPanel |
vgrid(List components)
Do a single column grid layout of the components |
static JPanel |
wrap(Component c)
Wrap the given component. |
static JPanel |
wrapLeft(Component c)
Wrap the given component, aligning it to the left. |
| Methods inherited from class ucar.unidata.util.MenuUtil |
|---|
findMethod, makeCheckboxMenuItem, makeCheckboxMenuItem, makeMenu, makeMenu, makeMenuItem, makeMenuItem, makeMenuItem, makeMenuItems, makePopupMenu, makePopupMenu, showPopupMenu, typesMatch |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static Insets tmpInsets
public static final Insets INSETS_5
public static final 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 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
| Constructor Detail |
|---|
public LayoutUtil()
| Method Detail |
|---|
public static void setNoFill()
public static JComponent hfill(JComponent comp)
comp - The component
public static void setHFill()
public static void setAnchorBottom()
public static void setAnchorTop()
public static JPanel inset(Component c,
int insetSize)
c - The component to wrapinsetSize - Horizontal and vertical inset
public static JPanel inset(Component c,
int insetSizeHor,
int insetSizeVert)
c - The component to wrapinsetSizeHor - Inset horizontalinsetSizeVert - Inset vertical
public static JPanel inset(Component c,
Insets insets)
c - The component to wrapinsets - The insets
public static JPanel wrapLeft(Component c)
c - The component to wrap
public static JPanel wrap(Component c)
c - The component to wrap
public static JPanel hflow(List components)
components - The components to layout
public static JPanel hflow(List components,
int hgap,
int vgap)
components - The components to layouthgap - Horizontal spacingvgap - Vertical spacing
public static JPanel hgrid(Component comp1,
Component comp2)
comp1 - comp1comp2 - comp2_
public static JPanel hgrid(List components)
components - The components to layout
public static JPanel hgrid(List components,
int space)
components - The components to layoutspace - The spacing
public static JPanel vgrid(List components)
components - The components to layout
public static JPanel vgrid(JPanel panel,
List components,
int space)
panel - The panel to add tocomponents - The components to layoutspace - The spacing
public static JPanel rowGrid(List comps,
int rows)
comps - Components to layoutrows - Number of rows
public static JPanel rowGrid(Component[] components,
int rows)
components - Components to layoutrows - Number of rows
public static JPanel colGrid(Component[] components,
int cols)
components - Components to layoutcols - Number of cols
public static JPanel grid(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 JPanel grid(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 - Spacing
public static JPanel inset(JPanel parent,
Component c,
int insetSize)
parent - The panel to put the component in.c - The component to wrapinsetSize - Horizontal and vertical inset
public static JPanel doLayout(List components,
int numberOfColumns,
int hinset,
int vinset)
components - List of Components to layoutnumberOfColumns - How many columns in the grid layouthinset - hor. insetvinset - vert. inset
public static Component[] getComponentArray(List listOfComponents)
listOfComponents - List of Components
public static JPanel doLayout(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 JPanel doLayout(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 JPanel doLayout(JPanel parentContainer,
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 JPanel vbox(Component c1,
Component c2)
c1 - Component 1c2 - Component 2
public static JPanel vbox(Component c1,
Component c2,
Component c3)
c1 - Component 1c2 - Component 2c3 - Component 3
public static JPanel vbox(Component c1,
Component c2,
Component c3,
Component c4)
c1 - Component 1c2 - Component 2c3 - Component 3c4 - Component 4
public static JPanel vbox(Component[] components)
components - The components
public static List toList(Object[] l)
public static JPanel vbox(List components)
components - The components
public static JPanel vbox(JPanel panel,
List components)
components - The componentspanel - The panel to put the components in if on-null.
public static JPanel leftVbox(List components)
components - The components
public static JPanel hbox(Component c1,
Component c2,
int spacing)
c1 - Component 1c2 - Component 2spacing - Inter component spacing
public static JPanel hbox(Component c1,
Component c2,
Component c3,
int spacing)
c1 - Component 1c2 - Component 2c3 - Component 3spacing - Inter component spacing
public static JPanel hbox(Component c1,
Component c2)
c1 - Component 1c2 - Component 2
public static JPanel hbox(Component c1,
Component c2,
Component c3)
c1 - Component 1c2 - Component 2c3 - Component 3
public static JPanel hbox(Component c1,
Component c2,
Component c3,
Component c4)
c1 - Component 1c2 - Component 2c3 - Component 3c4 - Component 4
public static JPanel hbox(List components,
int spacing)
components - The componentsspacing - The spacing
public static JPanel hbox(List components)
components - The components
public static JPanel hbox(Component[] components)
components - The components
public static JPanel hbox(Component[] components,
int spacing)
components - The componentsspacing - _more_
public static JPanel hbox(JPanel panel,
List components)
panel - The panel to use or, if null, we'll create a new on.components - The components
public static JPanel hbox(JPanel panel,
List components,
int space)
panel - The panel to use or, if null, we'll create a new on.components - The componentsspace - SPacing to use
public static JPanel doLayout(JPanel parentContainer,
Component[] components,
int numberOfColumns,
double[] weightsX,
double[] weightsY,
Hashtable anchors,
Hashtable fills,
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 grid
public static JPanel topLeft(Component top)
top - The component to place
public static JPanel top(Component top)
top - The component to place
public static JPanel left(Component left)
left - The component to place
public static JPanel topCenter(Component top,
Component center)
top - The top componentcenter - The center component
public static JPanel centerBottom(Component center,
Component bottom)
center - The center componentbottom - The bottom component
public static JPanel bottom(Component bottom)
bottom - The bottom component
public static JPanel center(Component center)
center - The center component
public static JPanel topCenterBottom(Component top,
Component center,
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 JPanel leftRight(Component left,
Component right)
left - The left componentright - The right component
public static JPanel leftCenterRight(Component left,
Component center,
Component right)
left - The left componentcenter - The center componentright - The right component
public static JPanel centerRight(Component center,
Component right)
center - The center componentright - The right component
public static JPanel right(Component right)
right - The right component
public static JPanel leftCenter(Component left,
Component center)
left - The left componentcenter - The center component
public static Component filler()
public static JComponent filler(int width,
int height)
width - filler widthheight - filler height
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||