How do I read values from the formAttachment in java?
up vote
1
down vote
favorite
How do I read values from the formAttachment
in Java?
here is my code:
Text one = new Text(composite, SWT.BORDER);
data = new FormData();
data.top = new FormAttachment(0, 0);
data.bottom = new FormAttachment(100, 0);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(sash, 0);
one.setLayoutData(data);
result:
java swt
add a comment |
up vote
1
down vote
favorite
How do I read values from the formAttachment
in Java?
here is my code:
Text one = new Text(composite, SWT.BORDER);
data = new FormData();
data.top = new FormAttachment(0, 0);
data.bottom = new FormAttachment(100, 0);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(sash, 0);
one.setLayoutData(data);
result:
java swt
BTW: which values do you want to read? Thenumerator
andoffset
values ofFormAttachment
or the text contained in theText
?
– Baz
Aug 5 '12 at 15:11
The numerator and offset
– Yrais
Aug 5 '12 at 16:54
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
How do I read values from the formAttachment
in Java?
here is my code:
Text one = new Text(composite, SWT.BORDER);
data = new FormData();
data.top = new FormAttachment(0, 0);
data.bottom = new FormAttachment(100, 0);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(sash, 0);
one.setLayoutData(data);
result:
java swt
How do I read values from the formAttachment
in Java?
here is my code:
Text one = new Text(composite, SWT.BORDER);
data = new FormData();
data.top = new FormAttachment(0, 0);
data.bottom = new FormAttachment(100, 0);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(sash, 0);
one.setLayoutData(data);
result:
java swt
java swt
edited Nov 10 at 15:03
Cœur
16.9k9102139
16.9k9102139
asked Aug 5 '12 at 14:48
Yrais
252
252
BTW: which values do you want to read? Thenumerator
andoffset
values ofFormAttachment
or the text contained in theText
?
– Baz
Aug 5 '12 at 15:11
The numerator and offset
– Yrais
Aug 5 '12 at 16:54
add a comment |
BTW: which values do you want to read? Thenumerator
andoffset
values ofFormAttachment
or the text contained in theText
?
– Baz
Aug 5 '12 at 15:11
The numerator and offset
– Yrais
Aug 5 '12 at 16:54
BTW: which values do you want to read? The
numerator
and offset
values of FormAttachment
or the text contained in the Text
?– Baz
Aug 5 '12 at 15:11
BTW: which values do you want to read? The
numerator
and offset
values of FormAttachment
or the text contained in the Text
?– Baz
Aug 5 '12 at 15:11
The numerator and offset
– Yrais
Aug 5 '12 at 16:54
The numerator and offset
– Yrais
Aug 5 '12 at 16:54
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
FormAttachment
s are used to position a Control
. You can fix the edges of a control by using the FormAttachment
for left, top, right or bottom. All remaining edges are calculated automatically.
The simplest possibility is the percentage positioning relative to the edges of the surrounding composite. Here is an example:
FormData formData = new FormData();
// Fix the left edge of the control to 25% of the overall width + 10px offset.
formData.left = new FormAttachment(25, 10);
// Fix the lower edge of the control to 75% of the overall height + 0px offset.
formData.bottom = new FormAttachment(75);
// Tell the control its new position.
control.setLayoutData(formData);
Alternativelyyou can use the contructor new FormAttachment(control, offset, alignment)
to fix an edge of a control relativ to an edge of another control:
FormData formData = new FormData();
// Fix left edge 10px to the right of the right edge of otherControl
formData.left = new FormAttachment(otherControl, 10, SWT.RIGHT);
// Fix bottom edge at exactly the same height as the one of otherControl
formData.bottom = new FormAttachment(otherControl, 0, SWT.BOTTOM);
control.setLayoutData(formData);
There is a really good Eclipse RCP manual by Ralf Ebert here. Unfortunately it is in German. However, you can find images explaining my examples above on the pages 56-57.
not so. I mean is how to read the numerator and offset. look at the picture. why the value of the "one.bottom" is 100?. full code is in java2s.com/Code/Java/SWT-JFace-Eclipse/DemonstratesaSash3.htm
– Yrais
Aug 5 '12 at 17:07
@Yrais If you are just trying to understand why they use100
in this example, I can't help you. However, I would suggest usingSashForm
which is much easier to use: java2s.com/Code/Java/SWT-JFace-Eclipse/SashFormExample.htm
– Baz
Aug 5 '12 at 17:09
not so. look at the picture. dat.top = new FormAttachment (0.0). "0" that assign it to the size where the picture? if (0.0) is (x, y) or x and y position. I can understand. but this (numerator, offset).
– Yrais
Aug 5 '12 at 17:44
@Yrais Then why don't you useSashForm
?
– Baz
Aug 5 '12 at 17:46
I want to know. I do not like something to prop my mind.
– Yrais
Aug 5 '12 at 18:00
|
show 1 more comment
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
FormAttachment
s are used to position a Control
. You can fix the edges of a control by using the FormAttachment
for left, top, right or bottom. All remaining edges are calculated automatically.
The simplest possibility is the percentage positioning relative to the edges of the surrounding composite. Here is an example:
FormData formData = new FormData();
// Fix the left edge of the control to 25% of the overall width + 10px offset.
formData.left = new FormAttachment(25, 10);
// Fix the lower edge of the control to 75% of the overall height + 0px offset.
formData.bottom = new FormAttachment(75);
// Tell the control its new position.
control.setLayoutData(formData);
Alternativelyyou can use the contructor new FormAttachment(control, offset, alignment)
to fix an edge of a control relativ to an edge of another control:
FormData formData = new FormData();
// Fix left edge 10px to the right of the right edge of otherControl
formData.left = new FormAttachment(otherControl, 10, SWT.RIGHT);
// Fix bottom edge at exactly the same height as the one of otherControl
formData.bottom = new FormAttachment(otherControl, 0, SWT.BOTTOM);
control.setLayoutData(formData);
There is a really good Eclipse RCP manual by Ralf Ebert here. Unfortunately it is in German. However, you can find images explaining my examples above on the pages 56-57.
not so. I mean is how to read the numerator and offset. look at the picture. why the value of the "one.bottom" is 100?. full code is in java2s.com/Code/Java/SWT-JFace-Eclipse/DemonstratesaSash3.htm
– Yrais
Aug 5 '12 at 17:07
@Yrais If you are just trying to understand why they use100
in this example, I can't help you. However, I would suggest usingSashForm
which is much easier to use: java2s.com/Code/Java/SWT-JFace-Eclipse/SashFormExample.htm
– Baz
Aug 5 '12 at 17:09
not so. look at the picture. dat.top = new FormAttachment (0.0). "0" that assign it to the size where the picture? if (0.0) is (x, y) or x and y position. I can understand. but this (numerator, offset).
– Yrais
Aug 5 '12 at 17:44
@Yrais Then why don't you useSashForm
?
– Baz
Aug 5 '12 at 17:46
I want to know. I do not like something to prop my mind.
– Yrais
Aug 5 '12 at 18:00
|
show 1 more comment
up vote
1
down vote
accepted
FormAttachment
s are used to position a Control
. You can fix the edges of a control by using the FormAttachment
for left, top, right or bottom. All remaining edges are calculated automatically.
The simplest possibility is the percentage positioning relative to the edges of the surrounding composite. Here is an example:
FormData formData = new FormData();
// Fix the left edge of the control to 25% of the overall width + 10px offset.
formData.left = new FormAttachment(25, 10);
// Fix the lower edge of the control to 75% of the overall height + 0px offset.
formData.bottom = new FormAttachment(75);
// Tell the control its new position.
control.setLayoutData(formData);
Alternativelyyou can use the contructor new FormAttachment(control, offset, alignment)
to fix an edge of a control relativ to an edge of another control:
FormData formData = new FormData();
// Fix left edge 10px to the right of the right edge of otherControl
formData.left = new FormAttachment(otherControl, 10, SWT.RIGHT);
// Fix bottom edge at exactly the same height as the one of otherControl
formData.bottom = new FormAttachment(otherControl, 0, SWT.BOTTOM);
control.setLayoutData(formData);
There is a really good Eclipse RCP manual by Ralf Ebert here. Unfortunately it is in German. However, you can find images explaining my examples above on the pages 56-57.
not so. I mean is how to read the numerator and offset. look at the picture. why the value of the "one.bottom" is 100?. full code is in java2s.com/Code/Java/SWT-JFace-Eclipse/DemonstratesaSash3.htm
– Yrais
Aug 5 '12 at 17:07
@Yrais If you are just trying to understand why they use100
in this example, I can't help you. However, I would suggest usingSashForm
which is much easier to use: java2s.com/Code/Java/SWT-JFace-Eclipse/SashFormExample.htm
– Baz
Aug 5 '12 at 17:09
not so. look at the picture. dat.top = new FormAttachment (0.0). "0" that assign it to the size where the picture? if (0.0) is (x, y) or x and y position. I can understand. but this (numerator, offset).
– Yrais
Aug 5 '12 at 17:44
@Yrais Then why don't you useSashForm
?
– Baz
Aug 5 '12 at 17:46
I want to know. I do not like something to prop my mind.
– Yrais
Aug 5 '12 at 18:00
|
show 1 more comment
up vote
1
down vote
accepted
up vote
1
down vote
accepted
FormAttachment
s are used to position a Control
. You can fix the edges of a control by using the FormAttachment
for left, top, right or bottom. All remaining edges are calculated automatically.
The simplest possibility is the percentage positioning relative to the edges of the surrounding composite. Here is an example:
FormData formData = new FormData();
// Fix the left edge of the control to 25% of the overall width + 10px offset.
formData.left = new FormAttachment(25, 10);
// Fix the lower edge of the control to 75% of the overall height + 0px offset.
formData.bottom = new FormAttachment(75);
// Tell the control its new position.
control.setLayoutData(formData);
Alternativelyyou can use the contructor new FormAttachment(control, offset, alignment)
to fix an edge of a control relativ to an edge of another control:
FormData formData = new FormData();
// Fix left edge 10px to the right of the right edge of otherControl
formData.left = new FormAttachment(otherControl, 10, SWT.RIGHT);
// Fix bottom edge at exactly the same height as the one of otherControl
formData.bottom = new FormAttachment(otherControl, 0, SWT.BOTTOM);
control.setLayoutData(formData);
There is a really good Eclipse RCP manual by Ralf Ebert here. Unfortunately it is in German. However, you can find images explaining my examples above on the pages 56-57.
FormAttachment
s are used to position a Control
. You can fix the edges of a control by using the FormAttachment
for left, top, right or bottom. All remaining edges are calculated automatically.
The simplest possibility is the percentage positioning relative to the edges of the surrounding composite. Here is an example:
FormData formData = new FormData();
// Fix the left edge of the control to 25% of the overall width + 10px offset.
formData.left = new FormAttachment(25, 10);
// Fix the lower edge of the control to 75% of the overall height + 0px offset.
formData.bottom = new FormAttachment(75);
// Tell the control its new position.
control.setLayoutData(formData);
Alternativelyyou can use the contructor new FormAttachment(control, offset, alignment)
to fix an edge of a control relativ to an edge of another control:
FormData formData = new FormData();
// Fix left edge 10px to the right of the right edge of otherControl
formData.left = new FormAttachment(otherControl, 10, SWT.RIGHT);
// Fix bottom edge at exactly the same height as the one of otherControl
formData.bottom = new FormAttachment(otherControl, 0, SWT.BOTTOM);
control.setLayoutData(formData);
There is a really good Eclipse RCP manual by Ralf Ebert here. Unfortunately it is in German. However, you can find images explaining my examples above on the pages 56-57.
edited Aug 5 '12 at 18:27
answered Aug 5 '12 at 16:58
Baz
31.2k115779
31.2k115779
not so. I mean is how to read the numerator and offset. look at the picture. why the value of the "one.bottom" is 100?. full code is in java2s.com/Code/Java/SWT-JFace-Eclipse/DemonstratesaSash3.htm
– Yrais
Aug 5 '12 at 17:07
@Yrais If you are just trying to understand why they use100
in this example, I can't help you. However, I would suggest usingSashForm
which is much easier to use: java2s.com/Code/Java/SWT-JFace-Eclipse/SashFormExample.htm
– Baz
Aug 5 '12 at 17:09
not so. look at the picture. dat.top = new FormAttachment (0.0). "0" that assign it to the size where the picture? if (0.0) is (x, y) or x and y position. I can understand. but this (numerator, offset).
– Yrais
Aug 5 '12 at 17:44
@Yrais Then why don't you useSashForm
?
– Baz
Aug 5 '12 at 17:46
I want to know. I do not like something to prop my mind.
– Yrais
Aug 5 '12 at 18:00
|
show 1 more comment
not so. I mean is how to read the numerator and offset. look at the picture. why the value of the "one.bottom" is 100?. full code is in java2s.com/Code/Java/SWT-JFace-Eclipse/DemonstratesaSash3.htm
– Yrais
Aug 5 '12 at 17:07
@Yrais If you are just trying to understand why they use100
in this example, I can't help you. However, I would suggest usingSashForm
which is much easier to use: java2s.com/Code/Java/SWT-JFace-Eclipse/SashFormExample.htm
– Baz
Aug 5 '12 at 17:09
not so. look at the picture. dat.top = new FormAttachment (0.0). "0" that assign it to the size where the picture? if (0.0) is (x, y) or x and y position. I can understand. but this (numerator, offset).
– Yrais
Aug 5 '12 at 17:44
@Yrais Then why don't you useSashForm
?
– Baz
Aug 5 '12 at 17:46
I want to know. I do not like something to prop my mind.
– Yrais
Aug 5 '12 at 18:00
not so. I mean is how to read the numerator and offset. look at the picture. why the value of the "one.bottom" is 100?. full code is in java2s.com/Code/Java/SWT-JFace-Eclipse/DemonstratesaSash3.htm
– Yrais
Aug 5 '12 at 17:07
not so. I mean is how to read the numerator and offset. look at the picture. why the value of the "one.bottom" is 100?. full code is in java2s.com/Code/Java/SWT-JFace-Eclipse/DemonstratesaSash3.htm
– Yrais
Aug 5 '12 at 17:07
@Yrais If you are just trying to understand why they use
100
in this example, I can't help you. However, I would suggest using SashForm
which is much easier to use: java2s.com/Code/Java/SWT-JFace-Eclipse/SashFormExample.htm– Baz
Aug 5 '12 at 17:09
@Yrais If you are just trying to understand why they use
100
in this example, I can't help you. However, I would suggest using SashForm
which is much easier to use: java2s.com/Code/Java/SWT-JFace-Eclipse/SashFormExample.htm– Baz
Aug 5 '12 at 17:09
not so. look at the picture. dat.top = new FormAttachment (0.0). "0" that assign it to the size where the picture? if (0.0) is (x, y) or x and y position. I can understand. but this (numerator, offset).
– Yrais
Aug 5 '12 at 17:44
not so. look at the picture. dat.top = new FormAttachment (0.0). "0" that assign it to the size where the picture? if (0.0) is (x, y) or x and y position. I can understand. but this (numerator, offset).
– Yrais
Aug 5 '12 at 17:44
@Yrais Then why don't you use
SashForm
?– Baz
Aug 5 '12 at 17:46
@Yrais Then why don't you use
SashForm
?– Baz
Aug 5 '12 at 17:46
I want to know. I do not like something to prop my mind.
– Yrais
Aug 5 '12 at 18:00
I want to know. I do not like something to prop my mind.
– Yrais
Aug 5 '12 at 18:00
|
show 1 more comment
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f11817357%2fhow-do-i-read-values-from-the-formattachment-in-java%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
BTW: which values do you want to read? The
numerator
andoffset
values ofFormAttachment
or the text contained in theText
?– Baz
Aug 5 '12 at 15:11
The numerator and offset
– Yrais
Aug 5 '12 at 16:54