Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Property Page: Sizing problems with ScrolledComposite
Property Page: Sizing problems with ScrolledComposite [message #438246] Thu, 17 June 2004 19:47
Chad Barnes is currently offline Chad BarnesFriend
Messages: 4
Registered: July 2009
Junior Member
I've been battling a problem for quite some time and have failed to come up
with a reliable solution.

I have created a property page in Eclipse and filled it with numerous
controls:

1)a tabfolder with multiple tabs
2)first TAB has a scrolledComposite
3)scrolledCOmposite contains a frame defined in a seperate class

The problem is when I open the project properties, and then select my
property page, the entire properties window resizes to the size of the
screen. I avoided this by placing a "getShell().setSize" command at the
beginning of my "createContents()" method, and then a "composite.pack()"
statement at the end. But, oddly enough, the size of the window AND contents
is fine the first time I open the properties page, but the second time I
open it (in the Eclipse session), the window is sized correctly but the
contents are sized as if the window was huge again. If I resize the window
at all (drag the frame), the contents resize down to the size of the window
and it looks good again.

I feel I am missing some basic discipline in SWT to avoid this
resizing/expanding problem. Does anyone have any suggestions. I would be
happy to post some code, but it is a monster createcontents() method.

[CODE]
protected Control createContents(Composite parent) {
final Composite controlParent = (Composite)super.getControl();
getShell().setSize(750, 675);
//final Composite controlParent = new Composite(parent, SWT.NONE);
//final GridLayout layout = new GridLayout();
//controlParent.setLayout(layout);
//controlParent.setLayoutData(new GridData(GridData.FILL_BOTH));
{
tabFolder = new TabFolder(controlParent, SWT.NONE);
GridData gd1 = new GridData(GridData.FILL_BOTH);
tabFolder.setLayoutData(gd1);
tabFolder.layout(true);
{
final TabItem tabBuildPaths = new TabItem(tabFolder, SWT.NONE);
tabBuildPaths.setText("Build Paths");
{
final ScrolledComposite scrolledComposite = new
ScrolledComposite(tabFolder, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
tabBuildPaths.setControl(scrolledComposite);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
scrolledComposite.setLayoutData(new
GridData(GridData.FILL_BOTH));
{
frameOne = new FrameOne(scrolledComposite, SWT.NONE);
frameOne.setSize(488, 265);
scrolledComposite.setContent(frameOne);
}
scrolledComposite.setMinSize(0,0);
}
}

{
.
.
.
}
//if this is missing, nothing is displayed on the property page
controlParent.pack();
return controlParent;
}

Code:

/*
* Created on Jun 17, 2004
*
*/
package com.rockwellcollins.property.sizeTest.properties;

import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.TableColumn;

/**
* @author cebarne2
*/
public class FrameOne extends Composite {

private Table table;
public FrameOne(Composite parent, int style) {
super(parent, style);
setLayout(new GridLayout());
{
table = new Table(this, SWT.BORDER);
table.setLayoutData(new GridData(GridData.FILL_BOTH));
table.setLinesVisible(true);
table.setHeaderVisible(true);
for (int i = 0; i < 10; i++)
{
final TableColumn tableColumn = new TableColumn(table,
SWT.NONE);
tableColumn.setWidth(100);
tableColumn.setText("New column " + String.valueOf(i));
}
TableItem ti;
for (int i = 0; i < 300; i++){
ti = new TableItem(table,SWT.NONE);
for (int j = 0; j < 10; j++)
ti.setText(j, String.valueOf(i));
}
}
}
public void dispose() {
super.dispose();
}
protected void checkSubclass() {}
}


Any ideas?
Previous Topic:How to let the scroll bar scrolls smartly?
Next Topic:Putting JavaEditor inside a Jface wizard?
Goto Forum:
  


Current Time: Fri Apr 26 18:00:15 GMT 2024

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

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

Back to the top