|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.swt.layout.FormAttachment
Instances of this class are used to define the edges of a control
within a FormLayout
.
FormAttachments
are set into the top, bottom, left,
and right fields of the FormData
for a control.
For example:
FormData data = new FormData(); data.top = new FormAttachment(0,5); data.bottom = new FormAttachment(100,-5); data.left = new FormAttachment(0,5); data.right = new FormAttachment(100,-5); button.setLayoutData(data);
A FormAttachment
defines where to attach the side of
a control by using the equation, y = ax + b. The "a" term represents
a fraction of the parent composite's width (from the left) or height
(from the top). It can be defined using a numerator and denominator,
or just a percentage value. If a percentage is used, the denominator
is set to 100. The "b" term in the equation represents an offset, in
pixels, from the attachment position. For example:
FormAttachment attach = new FormAttachment (20, -5);specifies that the side to which the
FormAttachment
object belongs will lie at 20% of the parent composite, minus 5 pixels.
Control sides can also be attached to another control. For example:
FormAttachment attach = new FormAttachment (button, 10);specifies that the side to which the
FormAttachment
object belongs will lie in the same position as the adjacent side of
the button
control, plus 10 pixels. The control side can
also be attached to the opposite side of the specified control.
For example:
FormData data = new FormData (); data.left = new FormAttachment (button, 0, SWT.LEFT);specifies that the left side of the control will lie in the same position as the left side of the
button
control. The control can also
be attached in a position that will center the control on the specified
control. For example:
data.left = new FormAttachment (button, 0, SWT.CENTER);specifies that the left side of the control will be positioned so that it is centered between the left and right sides of the
button
control.
If the alignment is not specified, the default is to attach to the adjacent side.
FormLayout
,
FormData
Field Summary | |
int |
alignment
alignment specifies the alignment of the control side that is attached to a control. |
Control |
control
control specifies the control to which the control side is attached. |
int |
denominator
denominator specifies the denominator of the "a" term in the equation, y = ax + b, which defines the attachment. |
int |
numerator
numerator specifies the numerator of the "a" term in the equation, y = ax + b, which defines the attachment. |
int |
offset
offset specifies the offset, in pixels, of the control side from the attachment position. |
Constructor Summary | |
FormAttachment(Control control)
Constructs a new instance of this class given a control. |
|
FormAttachment(Control control,
int offset)
Constructs a new instance of this class given a control and an offset. |
|
FormAttachment(Control control,
int offset,
int alignment)
Constructs a new instance of this class given a control, an offset and an alignment. |
|
FormAttachment(int numerator)
Constructs a new instance of this class given a numerator Since no denominator or offset is specified, the default is to treat the numerator as a percentage of the form, with a denominator of 100. |
|
FormAttachment(int numerator,
int offset)
Constructs a new instance of this class given a numerator and an offset. |
|
FormAttachment(int numerator,
int denominator,
int offset)
Constructs a new instance of this class given a numerator and denominator and an offset. |
Method Summary | |
java.lang.String |
toString()
Returns a string containing a concise, human-readable description of the receiver. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public int numerator
public int denominator
public int offset
public Control control
public int alignment
For top and bottom attachments, TOP, BOTTOM and CENTER are used. For left and right attachments, LEFT, RIGHT and CENTER are used. If any other case occurs, the default will be used instead.
Constructor Detail |
public FormAttachment(int numerator)
numerator
- the percentage of the positionpublic FormAttachment(int numerator, int offset)
numerator
- the percentage of the positionoffset
- the offset of the side from the positionpublic FormAttachment(int numerator, int denominator, int offset)
numerator
- the numerator of the positiondenominator
- the denominator of the positionoffset
- the offset of the side from the positionpublic FormAttachment(Control control)
control
- the control the side is attached topublic FormAttachment(Control control, int offset)
control
- the control the side is attached tooffset
- the offset of the side from the controlpublic FormAttachment(Control control, int offset, int alignment)
control
- the control the side is attached tooffset
- the offset of the side from the controlalignment
- the alignment of the side to the control it is attached toMethod Detail |
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |