|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgov.nasa.gsfc.drl.rtstps.library.layout.ScaledGridLayout
public final class ScaledGridLayout
This class is a layout manager that lays out components in an adjustable
grid. It is similar to GridLayout with several improvements. The rows and
columns are not the same size by default. GridLayout determines the width
of a column or the height of a row by using the maximum preferred size
of all components in that row or column. You can configure ScaledGridLayout
so that it does not grow a component beyond its maximum size. If a component
is smaller than its cell, it sizes it to its maximum size and places in the
cell based on the layout manager's X and Y alignments. Use
honorMaxSize(true)
to enable this feature. ScaledGridLayout
adds components in a specific order -- across a column before progressing to
the next row.
You may set hgap and vgap, which is the gap between components. The default is five pixels each. It does not apply to the border.
You may fix the size of columns or rows, which then work like GridLayout. All rows or columns are then the same size.
Use Box's struts, glue, and rigid to insert blank components.
You may set an inset, which is a blank border.
JPanel jp = new JPanel(new ScaledGridLayout(3,4)); //3 rows, 4 columns
jp.add(comp1);
jp.add(comp2);
Nested Class Summary | |
---|---|
(package private) class |
ScaledGridLayout.Axis
Manages all rows or all columns. |
Field Summary | |
---|---|
private float |
_alignX
|
private float |
_alignY
|
private ScaledGridLayout.Axis |
_columns
|
private int |
_hgap
|
private boolean |
_honorMaxSize
|
private java.awt.Insets |
_insets
|
private ScaledGridLayout.Axis |
_rows
|
private boolean |
_valid
|
private int |
_vgap
|
private static long |
serialVersionUID
|
Constructor Summary | |
---|---|
ScaledGridLayout()
Create a ScaledGridLayout object with one row and hgap=5, vgap=5. |
|
ScaledGridLayout(int rows,
int columns)
Create a ScaledGridLayout object with hgap=5 and vgap=5. |
|
ScaledGridLayout(int rows,
int columns,
int hgap,
int vgap)
Create a ScaledGridLayout object. |
|
ScaledGridLayout(int rows,
int columns,
int hgap,
int vgap,
boolean honorMaximumSize)
Create a ScaledGridLayout object. |
Method Summary | |
---|---|
void |
addLayoutComponent(java.awt.Component comp,
java.lang.Object constraints)
Adds the specified component to the layout using the specified constraint object. |
void |
addLayoutComponent(java.lang.String name,
java.awt.Component comp)
Adds the specified component with the specified name to the layout. |
java.awt.Insets |
getInsets()
Get the insets. |
float |
getLayoutAlignmentX(java.awt.Container parent)
Get the X alignment. |
float |
getLayoutAlignmentY(java.awt.Container parent)
Get the Y alignment. |
void |
honorMaxSize(boolean b)
If set to true, the layout manager will not increase any component's size above its maximum. |
void |
invalidateLayout(java.awt.Container target)
Cause the layout manager to lay out the components. |
void |
layoutContainer(java.awt.Container parent)
Lay out the container. |
private void |
locateInCell(java.awt.Component comp,
java.awt.Rectangle cell)
Position a component in a cell. |
java.awt.Dimension |
maximumLayoutSize(java.awt.Container parent)
Get the maximum layout size. |
java.awt.Dimension |
minimumLayoutSize(java.awt.Container parent)
Get the minimum layout size. |
java.awt.Dimension |
preferredLayoutSize(java.awt.Container parent)
Get the preferred layout size. |
void |
removeLayoutComponent(java.awt.Component comp)
Remove a component from the layout. |
void |
setFixedColumns(boolean ena)
Set fixed height columns. |
void |
setFixedRows(boolean ena)
Set fixed height rows. |
void |
setHgap(int gap)
Set the horizontal gap between units on a row. |
void |
setInsets(java.awt.Insets in)
Set insets, which is a blank border. |
void |
setLayoutAlignmentX(float x)
Set the horizontal alignment. |
void |
setLayoutAlignmentY(float y)
Set the vertical alignment. |
private void |
setLayoutHeight(java.awt.Container parent)
Compute the layout heights -- min, max, and preferred. |
private void |
setLayoutWidth(java.awt.Container parent)
Compute the layout widths -- min, max, and preferred. |
void |
setVgap(int gap)
Set the vertical gap between units in a column. |
private void |
validate(java.awt.Container parent)
Prepare the container for layout. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private ScaledGridLayout.Axis _rows
private ScaledGridLayout.Axis _columns
private java.awt.Insets _insets
private boolean _valid
private int _hgap
private int _vgap
private boolean _honorMaxSize
private float _alignX
private float _alignY
private static final long serialVersionUID
Constructor Detail |
---|
public ScaledGridLayout()
public ScaledGridLayout(int rows, int columns)
rows
- Number of rowscolumns
- Number of columnspublic ScaledGridLayout(int rows, int columns, int hgap, int vgap)
rows
- Number of rowscolumns
- Number of columnshgap
- Horizontal gap between units in a row.vgap
- Vertical gap between units in a column.public ScaledGridLayout(int rows, int columns, int hgap, int vgap, boolean honorMaximumSize)
rows
- Number of rowscolumns
- Number of columnshgap
- Horizontal gap between units in a row.vgap
- Vertical gap between units in a column.honorMaximumSize
- If true, the layout will not resize any
component above its maximum size.Method Detail |
---|
public final void setHgap(int gap)
public final void setVgap(int gap)
public final void honorMaxSize(boolean b)
public final void setInsets(java.awt.Insets in)
public final java.awt.Insets getInsets()
public final void setLayoutAlignmentX(float x)
x
- Floating point between 0f and 1f.public final void setLayoutAlignmentY(float y)
y
- Floating point between 0f and 1f.public final void setFixedRows(boolean ena)
GridLayout.
The default is false.
public final void setFixedColumns(boolean ena)
GridLayout.
The default is false.
public final void invalidateLayout(java.awt.Container target)
invalidateLayout
in interface java.awt.LayoutManager2
target
- The container in which the manager is working.public final void addLayoutComponent(java.lang.String name, java.awt.Component comp)
addLayoutComponent
in interface java.awt.LayoutManager
public final void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
addLayoutComponent
in interface java.awt.LayoutManager2
public final void removeLayoutComponent(java.awt.Component comp)
removeLayoutComponent
in interface java.awt.LayoutManager
public final float getLayoutAlignmentX(java.awt.Container parent)
getLayoutAlignmentX
in interface java.awt.LayoutManager2
public final float getLayoutAlignmentY(java.awt.Container parent)
getLayoutAlignmentY
in interface java.awt.LayoutManager2
public void layoutContainer(java.awt.Container parent)
layoutContainer
in interface java.awt.LayoutManager
private void locateInCell(java.awt.Component comp, java.awt.Rectangle cell)
public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
minimumLayoutSize
in interface java.awt.LayoutManager
public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
preferredLayoutSize
in interface java.awt.LayoutManager
public final java.awt.Dimension maximumLayoutSize(java.awt.Container parent)
maximumLayoutSize
in interface java.awt.LayoutManager2
private void validate(java.awt.Container parent)
private void setLayoutHeight(java.awt.Container parent)
private void setLayoutWidth(java.awt.Container parent)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |