|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PackAs
This interface is returned/used by the Packer layout manager. The methods are used to arrange the layout of components. The majority of these methods correspond directly to elements of the GridBagConstraints object and its use with the GridBagLayout layout manager. The purpose of this class is to make the use of these two objects simpler and less error prone by allowing the complete layout of an object to be specified in a single line of code, and to discourage the reuse of GridBagConstraint Objects which leads to subtle layout interactions.
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.
org.wonderly.awt.Packer
Method Summary | |
---|---|
PackAs |
add(java.awt.Component c)
Reuses the previous set of constraints to layout the passed Component. |
PackAs |
bottom()
Add gridy=REMAINDER to the constraints for the current component. |
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. |
PackAs |
gridh(int cnt)
Add gridheight=tot to the constraints for the current component. |
PackAs |
gridw(int cnt)
Add gridwidth=tot to the constraints for the current component. |
PackAs |
gridx(int pos)
Add gridx=tot to the constraints for the current component. |
PackAs |
gridy(int pos)
Add gridy=tot to the constraints for the current component. |
PackAs |
inset(java.awt.Insets insets)
Specifies the insets to apply to the component. |
PackAs |
inset(int top,
int left,
int bottom,
int right)
Specifies the insets to apply to the component. |
PackAs |
into(java.awt.Container cont)
Set the passed container as the container to pack future components into. |
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 c)
Creates a new set of constraints to layout the passed Component. |
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 gridx=REMAINDER to the constraints for the current component. |
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. |
Method Detail |
---|
PackAs into(java.awt.Container cont) throws java.lang.IllegalAccessException
java.lang.IllegalAccessException
- when the container is already set and
cloning the Packer instance fails.PackAs inset(java.awt.Insets insets)
insets
- the insets to applyPackAs inset(int top, int left, int bottom, int right)
left
- the left side inset.top
- the top inset.right
- the right side inset.bottom
- the bottom inset.PackAs north()
PackAs south()
PackAs east()
PackAs west()
PackAs northwest()
PackAs southwest()
PackAs northeast()
PackAs southeast()
PackAs left()
PackAs top()
PackAs right()
PackAs bottom()
PackAs gridx(int pos)
pos
- - the value to set gridx to.PackAs gridy(int pos)
pos
- - the value to set gridy to.PackAs gridh(int cnt)
cnt
- - the value to set gridheight to.PackAs gridw(int cnt)
cnt
- - the value to set gridwidth to.PackAs padx(int cnt)
cnt
- - the value to set ipadx to.PackAs pady(int cnt)
cnt
- - the value to set ipady to.PackAs fillx()
PackAs filly()
PackAs fillboth()
PackAs weightx(double wt)
wt
- - the value to set weightx to.PackAs weighty(double wt)
wt
- - the value to set weightx to.PackAs add(java.awt.Component c)
c
- The component to layout.PackAs pack(java.awt.Component c)
c
- The component to layout.PackAs remainx()
PackAs remainy()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |