Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to make my tree control wider?
How to make my tree control wider? [message #451924] Fri, 11 March 2005 01:16 Go to next message
Eclipse User
Originally posted by: zc.ssc.stn.sh.cn

I design a new preference page, and I want to display a tree on it:
protected Control createContents(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(1, false));

Group TestCase = new Group(composite,SWT.NONE);
TestCaseTree1 = new Tree(TestCase, SWT.NONE);
TestCaseTreeItem1 = new TreeItem(TestCaseTree1,SWT.NONE);
TestCaseTreeItem1.setText("domain1");
TestCaseTreeItem3 = new TreeItem(TestCaseTreeItem1,SWT.NONE);
TestCaseTreeItem3.setText("product11");
TestCaseTreeItem2 = new TreeItem(TestCaseTree1,SWT.NONE);
TestCaseTreeItem2.setText("domain2");
initLayoutAndData(TestCase,1);

return composite;
}

But in my preference page, the tree control is very narrow, how to make it
wider?
Re: How to make my tree control wider? [message #451943 is a reply to message #451924] Fri, 11 March 2005 10:19 Go to previous messageGo to next message
Grant Gayed is currently offline Grant Gayed
Messages: 2148
Registered: July 2009
Senior Member
You can specify a width hint for the Tree by setting a GridData layout data
object into it, for example:

TestCaseTree1.setLayoutData (new GridData (150,SWT.DEFAULT));

....requests a width of 150 pixels and does not try to influence the height.

Grant


"zc" <zc@ssc.stn.sh.cn> wrote in message
news:d0rd43$ig8$1@www.eclipse.org...
> I design a new preference page, and I want to display a tree on it:
> protected Control createContents(Composite parent) {
> Composite composite = new Composite(parent, SWT.NONE);
> composite.setLayout(new GridLayout(1, false));
>
> Group TestCase = new Group(composite,SWT.NONE);
> TestCaseTree1 = new Tree(TestCase, SWT.NONE);
> TestCaseTreeItem1 = new TreeItem(TestCaseTree1,SWT.NONE);
> TestCaseTreeItem1.setText("domain1");
> TestCaseTreeItem3 = new TreeItem(TestCaseTreeItem1,SWT.NONE);
> TestCaseTreeItem3.setText("product11");
> TestCaseTreeItem2 = new TreeItem(TestCaseTree1,SWT.NONE);
> TestCaseTreeItem2.setText("domain2");
> initLayoutAndData(TestCase,1);
>
> return composite;
> }
>
> But in my preference page, the tree control is very narrow, how to make it
> wider?
>
Re: How to make my tree control wider? [message #452029 is a reply to message #451943] Sun, 13 March 2005 23:01 Go to previous message
Eclipse User
Originally posted by: zc.ssc.stn.sh.cn

Thank you! I made it with your help.


Grant Gayed wrote:

> You can specify a width hint for the Tree by setting a GridData layout data
> object into it, for example:

> TestCaseTree1.setLayoutData (new GridData (150,SWT.DEFAULT));

> ....requests a width of 150 pixels and does not try to influence the height.

> Grant


> "zc" <zc@ssc.stn.sh.cn> wrote in message
> news:d0rd43$ig8$1@www.eclipse.org...
>> I design a new preference page, and I want to display a tree on it:
>> protected Control createContents(Composite parent) {
>> Composite composite = new Composite(parent, SWT.NONE);
>> composite.setLayout(new GridLayout(1, false));
>>
>> Group TestCase = new Group(composite,SWT.NONE);
>> TestCaseTree1 = new Tree(TestCase, SWT.NONE);
>> TestCaseTreeItem1 = new TreeItem(TestCaseTree1,SWT.NONE);
>> TestCaseTreeItem1.setText("domain1");
>> TestCaseTreeItem3 = new TreeItem(TestCaseTreeItem1,SWT.NONE);
>> TestCaseTreeItem3.setText("product11");
>> TestCaseTreeItem2 = new TreeItem(TestCaseTree1,SWT.NONE);
>> TestCaseTreeItem2.setText("domain2");
>> initLayoutAndData(TestCase,1);
>>
>> return composite;
>> }
>>
>> But in my preference page, the tree control is very narrow, how to make it
>> wider?
>>
Previous Topic:Menu Mnemonics not visible ?
Next Topic:JNI callback exception from custom SWT widget
Goto Forum:
  


Current Time: Thu Apr 17 05:54:09 EDT 2014

Powered by FUDForum. Page generated in 0.13838 seconds