Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Why is there a margin around the tree in this snippet?
Why is there a margin around the tree in this snippet? [message #452293] Thu, 17 March 2005 02:34 Go to next message
Eclipse UserFriend
Originally posted by: bob.objfac.com

And how do I get rid of it?

public static void main(String[] args) {
Display display = new Display ();

Shell shell = new Shell (display);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
shell.setLayout(layout);

Tree tree = new Tree (shell, SWT.BORDER);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
data.horizontalSpan = 1;
tree.setLayoutData(data);

for (int i=0; i<4; i++) {
TreeItem iItem = new TreeItem (tree, 0);
iItem.setText ("TreeItem (0) -" + i);
for (int j=0; j<4; j++) {
TreeItem jItem = new TreeItem (iItem, 0);
jItem.setText ("TreeItem (1) -" + j);
for (int k=0; k<4; k++) {
TreeItem kItem = new TreeItem (jItem, 0);
kItem.setText ("TreeItem (2) -" + k);
for (int l=0; l<4; l++) {
TreeItem lItem = new TreeItem (kItem, 0);
lItem.setText ("TreeItem (3) -" + l);
}
}
}
}
shell.open ();
while (!shell.isDisposed()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}

Thanks.

Bob Foster
Re: Why is there a margin around the tree in this snippet? [message #452299 is a reply to message #452293] Thu, 17 March 2005 07:57 Go to previous messageGo to next message
Stefan Pietsch is currently offline Stefan PietschFriend
Messages: 68
Registered: July 2009
Member
Hi Bob,

if I understand your question you only have to change SWT.BORDER to
SWT.NONE.

Bye Stefan

"Bob Foster" <bob@objfac.com> schrieb im Newsbeitrag
news:d1aqav$o0b$1@www.eclipse.org...
> And how do I get rid of it?
>
> public static void main(String[] args) {
> Display display = new Display ();
>
> Shell shell = new Shell (display);
> GridLayout layout = new GridLayout();
> layout.numColumns = 1;
> shell.setLayout(layout);
>
> Tree tree = new Tree (shell, SWT.BORDER);
> GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
> data.horizontalSpan = 1;
> tree.setLayoutData(data);
>
> for (int i=0; i<4; i++) {
> TreeItem iItem = new TreeItem (tree, 0);
> iItem.setText ("TreeItem (0) -" + i);
> for (int j=0; j<4; j++) {
> TreeItem jItem = new TreeItem (iItem, 0);
> jItem.setText ("TreeItem (1) -" + j);
> for (int k=0; k<4; k++) {
> TreeItem kItem = new TreeItem (jItem, 0);
> kItem.setText ("TreeItem (2) -" + k);
> for (int l=0; l<4; l++) {
> TreeItem lItem = new TreeItem (kItem, 0);
> lItem.setText ("TreeItem (3) -" + l);
> }
> }
> }
> }
> shell.open ();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
>
> Thanks.
>
> Bob Foster
Re: Why is there a margin around the tree in this snippet? [message #452308 is a reply to message #452293] Thu, 17 March 2005 12:32 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
layout.marginWidth = layout.marginHeight = 0;

The default margin width and height is 5 pixels.

"Bob Foster" <bob@objfac.com> wrote in message
news:d1aqav$o0b$1@www.eclipse.org...
> And how do I get rid of it?
>
> public static void main(String[] args) {
> Display display = new Display ();
>
> Shell shell = new Shell (display);
> GridLayout layout = new GridLayout();
> layout.numColumns = 1;
> shell.setLayout(layout);
>
> Tree tree = new Tree (shell, SWT.BORDER);
> GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
> data.horizontalSpan = 1;
> tree.setLayoutData(data);
>
> for (int i=0; i<4; i++) {
> TreeItem iItem = new TreeItem (tree, 0);
> iItem.setText ("TreeItem (0) -" + i);
> for (int j=0; j<4; j++) {
> TreeItem jItem = new TreeItem (iItem, 0);
> jItem.setText ("TreeItem (1) -" + j);
> for (int k=0; k<4; k++) {
> TreeItem kItem = new TreeItem (jItem, 0);
> kItem.setText ("TreeItem (2) -" + k);
> for (int l=0; l<4; l++) {
> TreeItem lItem = new TreeItem (kItem, 0);
> lItem.setText ("TreeItem (3) -" + l);
> }
> }
> }
> }
> shell.open ();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
>
> Thanks.
>
> Bob Foster
Re: Why is there a margin around the tree in this snippet? [message #452363 is a reply to message #452308] Fri, 18 March 2005 08:42 Go to previous message
Eclipse UserFriend
Originally posted by: bob.objfac.com

Bless you! It was not immediately obvious to me that this would be a
layout parameter vs. a layoutData parameter, but it makes total sense.

Bob Foster

Veronika Irvine wrote:
> layout.marginWidth = layout.marginHeight = 0;
>
> The default margin width and height is 5 pixels.
>
> "Bob Foster" <bob@objfac.com> wrote in message
> news:d1aqav$o0b$1@www.eclipse.org...
>
>>And how do I get rid of it?
>>
>> public static void main(String[] args) {
>> Display display = new Display ();
>>
>> Shell shell = new Shell (display);
>> GridLayout layout = new GridLayout();
>> layout.numColumns = 1;
>> shell.setLayout(layout);
>>
>> Tree tree = new Tree (shell, SWT.BORDER);
>> GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
>> data.horizontalSpan = 1;
>> tree.setLayoutData(data);
>>
>> for (int i=0; i<4; i++) {
>> TreeItem iItem = new TreeItem (tree, 0);
>> iItem.setText ("TreeItem (0) -" + i);
>> for (int j=0; j<4; j++) {
>> TreeItem jItem = new TreeItem (iItem, 0);
>> jItem.setText ("TreeItem (1) -" + j);
>> for (int k=0; k<4; k++) {
>> TreeItem kItem = new TreeItem (jItem, 0);
>> kItem.setText ("TreeItem (2) -" + k);
>> for (int l=0; l<4; l++) {
>> TreeItem lItem = new TreeItem (kItem, 0);
>> lItem.setText ("TreeItem (3) -" + l);
>> }
>> }
>> }
>> }
>> shell.open ();
>> while (!shell.isDisposed()) {
>> if (!display.readAndDispatch ()) display.sleep ();
>> }
>> display.dispose ();
>> }
>>
>>Thanks.
>>
>>Bob Foster
>
>
>
Previous Topic:Newbie-Question: JFace Actions with SWT Controls
Next Topic:Editable combo box
Goto Forum:
  


Current Time: Tue Oct 22 08:16:18 GMT 2019

Powered by FUDForum. Page generated in 0.02121 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top