|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--pnuts.awt.PnutsLayout
The PnutsLayout is a general purpose geometry manager. It is more user-friendly than any LayoutManager out there and as flexible as GridBagLayout. e.g.
setLayout(new PnutsLayout("cols = 3"));
add(button1, "ipadx = 20, ipady = 20");
add(button2, "padx = 20, pady = 20");
add(button3, "colspan = 2");
add(button4, "rowspan = 2");
add(button3, "halign = left, valign = top");
add(button3, "halign = right, valign = bottom");
add(button3, "halign = center, valign = fill");
| property | the meaning | default |
|---|---|---|
| cols | number of columns | 1 |
| uniform | if width and/or height of each columns are all same, "x", "y" or "xy" | "" |
| colspan | number of columns the component occupies | 1 |
| rowspan | number of rows the component occupies | 1 |
| padx | external padding (x) | 0 |
| pady | external padding (y) | 0 |
| ipadx | internal padding (x) | 0 |
| ipady | internal padding (y) | 0 |
| halign | alignment of x. One of "left", "right", "center", "fill" | center |
| valign | alignment of y. One of "top", "bottom", "center", "fill" | center |
| expand | expand as the size of container changes. one of "x", "y", "xy" | "" |
| Field Summary | |
protected int |
align
default align |
static int |
BOTTOM
|
static int |
CENTER
|
protected int |
cols
The number of columns |
static int |
H_FIT
|
protected int |
ipadx
default ipadx |
protected int |
ipady
default ipady |
static int |
LEFT
|
protected int |
padx
default padx |
protected int |
pady
default pady |
static int |
RIGHT
|
protected int |
rows
The number of rows |
static int |
TOP
|
static int |
V_FIT
|
protected boolean |
xfix
|
protected boolean |
yfix
|
| Constructor Summary | |
PnutsLayout()
construct a PnutsLayout |
|
PnutsLayout(int cols)
construct a PnutsLayout with specified number of columns |
|
PnutsLayout(int cols,
int padx,
int pady)
construct a PnutsLayout |
|
PnutsLayout(java.lang.String str)
|
|
| Method Summary | |
void |
addLayoutComponent(java.awt.Component comp,
java.lang.Object obj)
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. |
int |
getCols()
Get the number of columns |
int |
getColspan(java.awt.Component comp)
|
java.util.Hashtable |
getConstraints(java.awt.Component comp)
get a Hashtable of constraint for the specified component |
java.lang.String |
getConstraintString(java.awt.Component comp)
get a string representaion of constraint for the specified component |
java.lang.String |
getExpand(java.awt.Component comp)
|
java.awt.Point |
getGridPoint(java.awt.Container target,
int x,
int y)
get left-top point of the component(x,y) |
java.awt.Rectangle |
getGridRectangle(java.awt.Container target,
int idx)
get bounding-box for idx'th component |
java.lang.String |
getHAlign(java.awt.Component comp)
|
int |
getIPadX(java.awt.Component comp)
|
int |
getIPadY(java.awt.Component comp)
|
float |
getLayoutAlignmentX(java.awt.Container target)
Returns the alignment along the x axis. |
float |
getLayoutAlignmentY(java.awt.Container target)
Returns the alignment along the y axis. |
int |
getPadX(java.awt.Component comp)
|
int |
getPadY(java.awt.Component comp)
|
int |
getRows()
get the number of rows |
int |
getRowspan(java.awt.Component comp)
|
boolean[] |
getUniform()
get "uniform" property |
java.lang.String |
getVAlign(java.awt.Component comp)
|
void |
invalidateLayout(java.awt.Container target)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded. |
void |
layoutContainer(java.awt.Container target)
Lays out the container. |
java.awt.Dimension |
maximumLayoutSize(java.awt.Container target)
Returns the maximum size of this component. |
java.awt.Dimension |
minimumLayoutSize(java.awt.Container target)
Returns the minimum dimensions needed to layout the components contained in the specified target container. |
java.awt.Dimension |
preferredLayoutSize(java.awt.Container target)
Returns the preferred dimensions for this layout given the components in the specified target container. |
void |
removeLayoutComponent(java.awt.Component comp)
Removes the specified component from the layout. |
void |
setCols(int cols)
Set the number of columns |
void |
setColspan(java.awt.Component comp,
int colspan)
|
void |
setConstraints(java.awt.Component comp,
java.util.Hashtable table)
Specify layout constraints with Hashtable |
void |
setConstraints(java.awt.Component comp,
java.lang.String str)
Specify layout constraints with comma-separated list of " |
void |
setExpand(java.awt.Component comp,
java.lang.String ex)
|
void |
setHAlign(java.awt.Component comp,
java.lang.String s)
|
void |
setIPadding(java.awt.Component comp,
int x,
int y)
|
void |
setPadding(java.awt.Component comp,
int x,
int y)
|
void |
setRowspan(java.awt.Component comp,
int rowspan)
|
void |
setUniform(boolean x,
boolean y)
set "uniform" property |
void |
setVAlign(java.awt.Component comp,
java.lang.String s)
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
| Field Detail |
public static final int CENTER
public static final int TOP
public static final int BOTTOM
public static final int LEFT
public static final int RIGHT
public static final int V_FIT
public static final int H_FIT
protected int align
protected int padx
protected int pady
protected int ipadx
protected int ipady
protected int cols
protected int rows
protected boolean xfix
protected boolean yfix
| Constructor Detail |
public PnutsLayout()
public PnutsLayout(int cols)
cols - the number of columns
public PnutsLayout(int cols,
int padx,
int pady)
cols - the number of columnspadx - default external paddingpady - default external paddingpublic PnutsLayout(java.lang.String str)
| Method Detail |
public void addLayoutComponent(java.awt.Component comp,
java.lang.Object obj)
comp - the component to be added.obj - an object that determines how
the component is added to the layout.
Usage:
container.add(component, new Object[]{align, colspan, rowspan});
public void setConstraints(java.awt.Component comp,
java.lang.String str)
comp - the componentstr - a string that describes how
the component is added to the layout.
public void setConstraints(java.awt.Component comp,
java.util.Hashtable table)
comp - the component to be set the constraint.table - a Hashtable that describes how
the component is added to the layout.public java.lang.String getConstraintString(java.awt.Component comp)
comp - the component to be investigatepublic java.util.Hashtable getConstraints(java.awt.Component comp)
comp - the component to be investigate
public void addLayoutComponent(java.lang.String name,
java.awt.Component comp)
name - the component namecomp - the component to be addedpublic void removeLayoutComponent(java.awt.Component comp)
comp - the component ot be removedpublic java.awt.Dimension maximumLayoutSize(java.awt.Container target)
Component.getMinimumSize(),
Component.getPreferredSize(),
LayoutManagerpublic float getLayoutAlignmentX(java.awt.Container target)
public float getLayoutAlignmentY(java.awt.Container target)
public void invalidateLayout(java.awt.Container target)
target - container to invalidate the layoutpublic void setCols(int cols)
cols - the number of columns
public void setUniform(boolean x,
boolean y)
x - uniform property for horizontal directiony - uniform property for vertical directionpublic boolean[] getUniform()
public void setColspan(java.awt.Component comp,
int colspan)
comp - the component of which you want to change colspancolspan - the number of columns the component occupiespublic int getColspan(java.awt.Component comp)
comp - the component of which you want to get colspan
public void setRowspan(java.awt.Component comp,
int rowspan)
comp - the component of which you want to change rowspanrowspan - the number of rows the component occupiespublic int getRowspan(java.awt.Component comp)
comp - the component of which you want to get rowspan
public void setHAlign(java.awt.Component comp,
java.lang.String s)
comp - the component of which you want to change alignmentalign - "left", "right", "fill", "center"
public void setVAlign(java.awt.Component comp,
java.lang.String s)
comp - the component of which you want to change alignmentalign - "top", "bottom", "fill", "center"public java.lang.String getHAlign(java.awt.Component comp)
comp - the component of which you want to get alignmentpublic java.lang.String getVAlign(java.awt.Component comp)
comp - the component of which you want to get alignment
public void setExpand(java.awt.Component comp,
java.lang.String ex)
comp - the component of which you want to set "expand"public java.lang.String getExpand(java.awt.Component comp)
comp - the component of which you want to get "expand"
public void setPadding(java.awt.Component comp,
int x,
int y)
comp - the component of which you want to change alignmentx - "padx" propertyy - "pady" propertypublic int getPadX(java.awt.Component comp)
comp - the component of which you want to get "padx"public int getPadY(java.awt.Component comp)
comp - the component of which you want to get "pady"
public void setIPadding(java.awt.Component comp,
int x,
int y)
comp - the component of which you want to change alignmentx - "ipadx" propertyy - "ipady" propertypublic int getIPadX(java.awt.Component comp)
comp - the component of which you want to get "ipadx"public int getIPadY(java.awt.Component comp)
comp - the component of which you want to get "ipady"public java.awt.Dimension preferredLayoutSize(java.awt.Container target)
target - the component which needs to be laid outContainer,
minimumLayoutSize(java.awt.Container)public java.awt.Dimension minimumLayoutSize(java.awt.Container target)
target - the component which needs to be laid outpreferredLayoutSize(java.awt.Container)public void layoutContainer(java.awt.Container target)
target - the specified component being laid out.Containerpublic int getCols()
public int getRows()
public java.awt.Point getGridPoint(java.awt.Container target,
int x,
int y)
x - the index of columny - the index of row
public java.awt.Rectangle getGridRectangle(java.awt.Container target,
int idx)
idx - the index of the componentpublic java.lang.String toString()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||