|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.GridBagLayout
com.moneydance.awt.Packer
public class Packer
The Packer class extends the GridBagLayout to provide a method based interface to this class. This makes it possible to position several widgets into a GridBagLayout without resetting various values in a GridBagLayout instance. All methods return the PackAs interface which allows the reuse of a particular layout strategy for subsequent widgets via the add() method.
Panel p = new Panel(); // Create new Panel container Label l = new Label( "label: " ); // Create a label Component TextField t = new TextField( 30 ); // Create a TextField Component Packer pk = new Packer(p); // Create Layout and setLayout on container pk.pack( l ).gridx(0); // Add to Container and layout pk.pack( t ).gridx(1).fillx(); // Add to Container and layout
Pay attention to the fact that fillx(), filly() and fillboth() change the weights of the respective axis. This is done to unify the expansion factors to equally distribute the components if you do not specify weight[xy] values. If you do not specify the weight[xy] values, they default to 1. Thus, you must always put the weight[xy]() after the fill[xy]() if you want something different than equal expansion.
When putting several buttons into a JPanel, you can use
...fillx().weightx(0)
to make all of them the same width,
but keep the JPanel from being any wider than the widest button.
Field Summary | |
---|---|
protected java.awt.Component |
comp
The component currently being layed out. |
protected java.awt.Container |
container
If the Packer( Container ) constructor is used, this member contains a reference to the container that this instance provides layout for. |
protected java.awt.GridBagConstraints |
gc
The current constraints used for subsequent uses of the PackAs interface returned by the methods below. |
Fields inherited from class java.awt.GridBagLayout |
---|
columnWeights, columnWidths, comptable, defaultConstraints, layoutInfo, MAXGRIDSIZE, MINSIZE, PREFERREDSIZE, rowHeights, rowWeights |
Constructor Summary | |
---|---|
Packer()
Create a new Packer instance. |
|
Packer(java.awt.Container cont)
Creates a new Packer instance that is used to layout the passed container. |
Method Summary | |
---|---|
PackAs |
add(java.awt.Component cp)
Reuses the previous set of constraints to layout the widget passed |
PackAs |
bottom()
Add gridheight=RELATIVE to the constraints for the current component. |
java.lang.Object |
clone()
Create a copy of this Packer Object. |
PackAs |
east()
Add anchor=EAST to the constraints for the current component. |
PackAs |
fillboth()
Add fill=BOTH, weighty=1, weightx=1 to the constraints for the current component. |
PackAs |
fillx()
Add fill=HORIZONTAL, weightx=1 to the constraints for the current component. |
PackAs |
filly()
Add fill=VERTICAL, weighty=1 to the constraints for the current component. |
boolean |
getAnchorEast()
|
boolean |
getAnchorNorth()
|
boolean |
getAnchorNorthEast()
|
boolean |
getAnchorNorthWest()
|
boolean |
getAnchorSouth()
|
boolean |
getAnchorSouthEast()
|
boolean |
getAnchorSouthWest()
|
boolean |
getAnchorWest()
|
java.awt.Container |
getContainer()
Get the designated container for this instance. |
boolean |
getFillBoth()
|
boolean |
getFillX()
|
boolean |
getFillY()
|
int |
getGridH()
|
int |
getGridW()
|
int |
getGridX()
|
int |
getGridY()
|
int |
getInsetBottom()
|
int |
getInsetLeft()
|
int |
getInsetRight()
|
int |
getInsetTop()
|
int |
getPadX()
|
int |
getPadY()
|
boolean |
getRemainX()
|
boolean |
getRemainY()
|
double |
getWeightX()
|
double |
getWeightY()
|
boolean |
getXLeftRelative()
|
boolean |
getXRightRelative()
|
boolean |
getYBottomRelative()
|
boolean |
getYTopRelative()
|
PackAs |
gridh(int tot)
Add gridheight=tot to the constraints for the current component. |
PackAs |
gridw(int tot)
Add gridwidth=tot to the constraints for the current component. |
PackAs |
gridx(int tot)
Add gridx=tot to the constraints for the current component. |
PackAs |
gridy(int tot)
Add gridy=tot to the constraints for the current component. |
PackAs |
inset(java.awt.Insets insets)
Specify the insets for the component. |
PackAs |
inset(int top,
int left,
int bottom,
int right)
Specify the insets for the component. |
PackAs |
into(java.awt.Container cont)
This method is used to specify the container that the next component that is added or packed will be placed in. |
PackAs |
left()
Add gridx=RELATIVE to the constraints for the current component. |
PackAs |
north()
Add anchor=NORTH to the constraints for the current component. |
PackAs |
northeast()
Add anchor=NORTHEAST to the constraints for the current component. |
PackAs |
northwest()
Add anchor=NORTHWEST to the constraints for the current component. |
PackAs |
pack(java.awt.Component cp)
Establishes a new set of constraints to layout the widget passed. |
PackAs |
padx(int cnt)
Add ipadx=cnt to the constraints for the current component. |
PackAs |
pady(int cnt)
Add ipady=cnt to the constraints for the current component. |
PackAs |
remainx()
Add gridwidth=REMAINDER to the constraints for the current component. |
PackAs |
remainy()
Add gridheight=REMAINDER to the constraints for the current component. |
PackAs |
right()
Add gridwidth=RELATIVE to the constraints for the current component. |
PackAs |
setAnchorEast(boolean how)
Add anchor=EAST to the constraints for the current component if how == true remove it if false. |
PackAs |
setAnchorNorth(boolean how)
Add anchor=NORTH to the constraints for the current component if how == true remove it if false. |
PackAs |
setAnchorNorthEast(boolean how)
Add anchor=NORTHEAST to the constraints for the current component if how == true remove it if false. |
PackAs |
setAnchorNorthWest(boolean how)
Add anchor=NORTHWEST to the constraints for the current component if how == true remove it if false. |
PackAs |
setAnchorSouth(boolean how)
Add anchor=SOUTH to the constraints for the current component if how == true remove it if false. |
PackAs |
setAnchorSouthEast(boolean how)
Add anchor=SOUTHEAST to the constraints for the current component if how == true remove it if false. |
PackAs |
setAnchorSouthWest(boolean how)
Add anchor=SOUTHWEST to the constraints for the current component if how == true remove it if false. |
PackAs |
setAnchorWest(boolean how)
Add anchor=WEST to the constraints for the current component if how == true remove it if false. |
PackAs |
setContainer(java.awt.Container cont)
Set the designated container for objects packed by this instance. |
PackAs |
setFillBoth(boolean how)
Add fill=BOTH, weightx=1, weighty=1 to the constraints for the current component if how == true, fill=0, weightx=0, weighty=0 if it is false. |
PackAs |
setFillX(boolean how)
Add fill=HORIZONTAL, weightx=1 to the constraints for the current component if how == true. |
PackAs |
setFillY(boolean how)
Add fill=VERITCAL to the constraints for the current component if how == true 1 it if false. |
PackAs |
setInsetBottom(int val)
sets bottom Insets on the constraints for the current component to the value specified. |
PackAs |
setInsetLeft(int val)
sets left Insets on the constraints for the current component to the value specified. |
PackAs |
setInsetRight(int val)
sets right Insets on the constraints for the current component to the value specified. |
PackAs |
setInsetTop(int val)
sets top Insets on the constraints for the current component to the value specified. |
PackAs |
setRemainX(boolean how)
Add gridWidth=REMAINDER to the constraints for the current component if how == true 1 it if false. |
PackAs |
setRemainY(boolean how)
Add gridWidth=REMAINDER to the constraints for the current component if how == true 1 it if false. |
PackAs |
setXLeftRelative(boolean how)
Add gridx=RELATIVE to the constraints for the current component if how == true 0 it if false. |
PackAs |
setXRightRelative(boolean how)
Add gridWidth=RELATIVE to the constraints for the current component if how == true 1 it if false. |
PackAs |
setYBottomRelative(boolean how)
Add gridWidth=RELATIVE to the constraints for the current component if how == true 1 it if false. |
PackAs |
setYTopRelative(boolean how)
Add gridy=RELATIVE to the constraints for the current component if how == true 0 it if false. |
PackAs |
south()
Add anchor=SOUTH to the constraints for the current component. |
PackAs |
southeast()
Add anchor=SOUTHEAST to the constraints for the current component. |
PackAs |
southwest()
Add anchor=SOUTHWEST to the constraints for the current component. |
PackAs |
top()
Add gridy=RELATIVE to the constraints for the current component. |
PackAs |
weightx(double wt)
Add weightx=wt to the constraints for the current component. |
PackAs |
weighty(double wt)
Add weighty=wt to the constraints for the current component. |
PackAs |
west()
Add anchor=WEST to the constraints for the current component. |
Methods inherited from class java.awt.GridBagLayout |
---|
addLayoutComponent, addLayoutComponent, adjustForGravity, AdjustForGravity, arrangeGrid, ArrangeGrid, getConstraints, getLayoutAlignmentX, getLayoutAlignmentY, getLayoutDimensions, getLayoutInfo, GetLayoutInfo, getLayoutOrigin, getLayoutWeights, getMinSize, GetMinSize, invalidateLayout, layoutContainer, location, lookupConstraints, maximumLayoutSize, minimumLayoutSize, preferredLayoutSize, removeLayoutComponent, setConstraints, toString |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.awt.GridBagConstraints gc
protected java.awt.Component comp
protected java.awt.Container container
Constructor Detail |
---|
public Packer()
public Packer(java.awt.Container cont)
Method Detail |
---|
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- if strange clone errors occurpublic PackAs setContainer(java.awt.Container cont) throws java.lang.IllegalAccessException
cont
- the Container to use to add the components to when
.pack() or .add() is invoked.
java.lang.IllegalAccessException
- if container already setpublic java.awt.Container getContainer()
public PackAs into(java.awt.Container cont) throws java.lang.IllegalAccessException
into
in interface PackAs
cont
- The container to place future components into.
java.lang.IllegalAccessException
- if container is already setpublic PackAs pack(java.awt.Component cp)
pack
in interface PackAs
cp
- The component to layout.public PackAs add(java.awt.Component cp)
add
in interface PackAs
cp
- The component to layout. It must be added to the
Container owning this LayoutManager by the calling code.public PackAs setAnchorNorth(boolean how)
public boolean getAnchorNorth()
public PackAs north()
north
in interface PackAs
public PackAs setAnchorSouth(boolean how)
public boolean getAnchorSouth()
public PackAs south()
south
in interface PackAs
public PackAs setAnchorEast(boolean how)
public boolean getAnchorEast()
public PackAs east()
east
in interface PackAs
public PackAs setAnchorWest(boolean how)
public boolean getAnchorWest()
public PackAs west()
west
in interface PackAs
public PackAs setAnchorNorthWest(boolean how)
public boolean getAnchorNorthWest()
public PackAs northwest()
northwest
in interface PackAs
public PackAs setAnchorSouthWest(boolean how)
public boolean getAnchorSouthWest()
public PackAs southwest()
southwest
in interface PackAs
public PackAs setAnchorNorthEast(boolean how)
public boolean getAnchorNorthEast()
public PackAs northeast()
northeast
in interface PackAs
public PackAs setAnchorSouthEast(boolean how)
public boolean getAnchorSouthEast()
public PackAs southeast()
southeast
in interface PackAs
public PackAs setXLeftRelative(boolean how)
public boolean getXLeftRelative()
public PackAs left()
left
in interface PackAs
public PackAs setYTopRelative(boolean how)
public boolean getYTopRelative()
public PackAs top()
top
in interface PackAs
public PackAs setXRightRelative(boolean how)
public boolean getXRightRelative()
public PackAs right()
right
in interface PackAs
public PackAs setYBottomRelative(boolean how)
public boolean getYBottomRelative()
public PackAs bottom()
bottom
in interface PackAs
public PackAs gridx(int tot)
gridx
in interface PackAs
tot
- - the value to set gridx to.public int getGridX()
public PackAs gridy(int tot)
gridy
in interface PackAs
tot
- - the value to set gridy to.public int getGridY()
public PackAs gridw(int tot)
gridw
in interface PackAs
tot
- - the value to set gridwidth to.public int getGridW()
public PackAs gridh(int tot)
gridh
in interface PackAs
tot
- - the value to set gridheight to.public int getGridH()
public PackAs padx(int cnt)
padx
in interface PackAs
cnt
- - the value to set ipadx to.public int getPadX()
public PackAs pady(int cnt)
pady
in interface PackAs
cnt
- - the value to set ipady to.public int getPadY()
public PackAs setFillX(boolean how)
public boolean getFillX()
public PackAs fillx()
fillx
in interface PackAs
public PackAs setFillY(boolean how)
public boolean getFillY()
public PackAs filly()
filly
in interface PackAs
public PackAs setFillBoth(boolean how)
public boolean getFillBoth()
public PackAs fillboth()
fillboth
in interface PackAs
public PackAs inset(java.awt.Insets insets)
inset
in interface PackAs
insets
- the insets to applypublic PackAs setInsetTop(int val)
public int getInsetTop()
public int getInsetBottom()
public int getInsetLeft()
public int getInsetRight()
public PackAs setInsetBottom(int val)
public PackAs setInsetLeft(int val)
public PackAs setInsetRight(int val)
public PackAs inset(int top, int left, int bottom, int right)
inset
in interface PackAs
left
- the inset from the left.top
- the inset from the top.right
- the inset from the right.bottom
- the inset from the bottom.public PackAs weightx(double wt)
weightx
in interface PackAs
wt
- - the value to set weightx to.public double getWeightX()
public double getWeightY()
public PackAs weighty(double wt)
weighty
in interface PackAs
wt
- - the value to set weightx to.public PackAs setRemainX(boolean how)
public boolean getRemainX()
public PackAs remainx()
remainx
in interface PackAs
public PackAs setRemainY(boolean how)
public boolean getRemainY()
public PackAs remainy()
remainy
in interface PackAs
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |