Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Layouts
Layouts [message #461047] Thu, 15 September 2005 08:41 Go to next message
Eclipse UserFriend
Originally posted by: davidyoung_2001.yahoo.co.uk

I'm trying to create a "Thunderbird" type layout, with a folders view on
the left (full height) and then the left hand side split into two panes
(top and bottom). All the windows need to be re-sized by draging......

I have the following code but I'n struggling as to how to get the sash
working between the top and bottom views....HELP

package Test;

import org.eclipse.swt.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class test {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Test");
shell.setLayout(new FillLayout());

SashForm form = new SashForm(shell, SWT.HORIZONTAL);

Composite leftComposite = new Composite(form, SWT.BORDER);
leftComposite.setLayout(new RowLayout());

final Composite rightComposite = new Composite(form, SWT.BORDER);
rightComposite.setLayout(new FormLayout());


Composite compositeTheNEW = new Composite(rightComposite, SWT.NONE);
FormData compositeFormDataTheNEW = new FormData();
compositeFormDataTheNEW.left = new FormAttachment(0, 0);
compositeFormDataTheNEW.right = new FormAttachment(100, 0);
compositeFormDataTheNEW.top = new FormAttachment(0, 0);
compositeFormDataTheNEW.bottom = new FormAttachment(100, 0);
compositeTheNEW.setLayoutData(compositeFormDataTheNEW);
compositeTheNEW.setLayout(new FormLayout());

Composite composite2 = new Composite(compositeTheNEW, SWT.BORDER);
FormData composite2FormData = new FormData();
composite2FormData.left = new FormAttachment(0, 4);
composite2FormData.right = new FormAttachment(100, -4);
composite2FormData.top = new FormAttachment(0, 4);
composite2FormData.bottom = new FormAttachment(50, -4);
composite2.setLayoutData(composite2FormData);
//composite2.setLayout(new RowLayout());

Composite composite3 = new Composite(compositeTheNEW, SWT.BORDER);
FormData composite3FormData = new FormData();
composite3FormData.left = new FormAttachment(0, 4);
composite3FormData.right = new FormAttachment(100, -4);
composite3FormData.top = new FormAttachment(composite2, 4);
composite3FormData.bottom = new FormAttachment(100, -4);
composite3.setLayoutData(composite3FormData);

form.setWeights(new int[] {30, 70});

shell.setSize(800, 600);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
Re: Layouts [message #461051 is a reply to message #461047] Thu, 15 September 2005 09:07 Go to previous messageGo to next message
hortiz Mising name is currently offline hortiz Mising nameFriend
Messages: 96
Registered: July 2009
Member
Hi David,

The problem is that you've created only one SashForm instance.

Here is the code modified:

package Test;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class test {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Test");
shell.setLayout(new FillLayout());

SashForm form = new SashForm(shell, SWT.HORIZONTAL);

Composite leftComposite = new Composite(form, SWT.BORDER);
leftComposite.setLayout(new RowLayout());

final Composite rightComposite = new Composite(form, SWT.BORDER);
rightComposite.setLayout(new GridLayout());

SashForm sashForm2 = new SashForm(rightComposite, SWT.VERTICAL);
sashForm2.setLayout(new GridLayout());
GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.verticalAlignment = GridData.FILL;
sashForm2.setLayoutData(gridData);

Composite composite2 = new Composite(sashForm2, SWT.BORDER);
gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.verticalAlignment = GridData.FILL;
composite2.setLayoutData(gridData);

Composite composite3 = new Composite(sashForm2, SWT.BORDER);
gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.verticalAlignment = GridData.FILL;
composite3.setLayoutData(gridData);


form.setWeights(new int[] {30, 70});

shell.setSize(800, 600);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
Re: Layouts [message #461068 is a reply to message #461051] Thu, 15 September 2005 12:46 Go to previous message
Eclipse UserFriend
Originally posted by: davidyoung_2001.yahoo.co.uk

Thank you very much - I've been trying to get this to work for weeks
(newcomer to JAVA)
Previous Topic:How to specify TitleAreaDialog's position when it startup
Next Topic:Eclipse 3.1 : dynamic menu from menu bar
Goto Forum:
  


Current Time: Fri Apr 19 19:03:23 GMT 2024

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

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

Back to the top