How do I read values from the formAttachment in java?









up vote
1
down vote

favorite
1












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:



one is left










share|improve this question























  • 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














up vote
1
down vote

favorite
1












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:



one is left










share|improve this question























  • 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












up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





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:



one is left










share|improve this question















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:



one is left







java swt






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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? 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
















  • 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















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












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










FormAttachments 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.






share|improve this answer






















  • 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










  • 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










  • I want to know. I do not like something to prop my mind.
    – Yrais
    Aug 5 '12 at 18:00










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










FormAttachments 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.






share|improve this answer






















  • 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










  • 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










  • I want to know. I do not like something to prop my mind.
    – Yrais
    Aug 5 '12 at 18:00














up vote
1
down vote



accepted










FormAttachments 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.






share|improve this answer






















  • 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










  • 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










  • I want to know. I do not like something to prop my mind.
    – Yrais
    Aug 5 '12 at 18:00












up vote
1
down vote



accepted







up vote
1
down vote



accepted






FormAttachments 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.






share|improve this answer














FormAttachments 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.







share|improve this answer














share|improve this answer



share|improve this answer








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 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










  • @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
















  • 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










  • 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










  • 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

















 

draft saved


draft discarded















































 


draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3

Museum of Modern and Contemporary Art of Trento and Rovereto