Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » control the size of a table
control the size of a table [message #461273] Tue, 20 September 2005 09:08 Go to next message
martin is currently offline martinFriend
Messages: 49
Registered: July 2009
Member
Hello together,

I've got problems to control the size of two tables in a rather complex
gridLayout. In my layout I've got an AWT Frame (within a new Composite)
beyond the two tables. If they get lots of entries, they grab the whole
space to the lower bound of my application window and do not even show a
scrollbar. Currently the tables are within an own class (extends
Composite), like the following:

public class CoordTableContainer extends Composite {
CoordTableContainer(Composite parent, int style) {
super(parent, style);
Table tab2 = new Table(this, SWT.BORDER);
[...]
}

and a different class takes care of the gridLayout, like that:

coordTableContainer = new CoordTableContainer(this, SWT.NONE);
GridData gridDataCoord = new GridData(SWT.FILL, SWT.FILL, true, true, 2,
12);
coordTableContainer.setLayoutData(gridDataCoord);

So what can one do to set the size of an externalized (via Composite) table
and force it to use scrollbars? I'm lost ...

Martin
Re: control the size of a table [message #461717 is a reply to message #461273] Wed, 28 September 2005 09:23 Go to previous messageGo to next message
martin is currently offline martinFriend
Messages: 49
Registered: July 2009
Member
finally I managed at least to give those two tables their scrollbars by
making use of a ScrolledComposite in which they are nested.

Martin Röhricht wrote:
> and a different class takes care of the gridLayout, like that:
>
> coordTableContainer = new CoordTableContainer(this, SWT.NONE);
> GridData gridDataCoord = new GridData(SWT.FILL, SWT.FILL, true, true, 2,
> 12);
> coordTableContainer.setLayoutData(gridDataCoord);

Now I've got there:

final ScrolledComposite sc1 = new ScrolledComposite(this, SWT.V_SCROLL |
SWT.BORDER);
coordTableContainer = new coordTableContainer(sc1, SWT.NONE);
sc1.setContent(coordTableContainer);
coordTableContainer.pack();
sc1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 12));

But sadly I've still the problem to manage the size of those two
Tables/ScrolledComposites. Everything is well ordered, but I would like to
see them grabing less space than currently.

Any ideas about that?

Martin
Re: control the size of a table [message #462099 is a reply to message #461717] Thu, 06 October 2005 11:44 Go to previous message
martin is currently offline martinFriend
Messages: 49
Registered: July 2009
Member
Martin Röhricht wrote:
> But sadly I've still the problem to manage the size of those two
> Tables/ScrolledComposites. Everything is well ordered, but I would like to
> see them grabing less space than currently.

Using a GridLayout, I had to give the GridData a heighHint and set this
GridData as the LayoutData for the Composite in which the table is placed.
Example:
-----------------------8<--------------------------
final ScrolledComposite sc1 = new ScrolledComposite(shell,
SWT.V_SCROLL | SWT.BORDER);
Table tableWater = new Table(sc1, SWT.NONE);
tableWater.setHeaderVisible(true);
tableWater.setLinesVisible(true);
TableColumn columnWater = new TableColumn(tableWater, SWT.NONE);
columnWater.setText("Water");
TableColumn columnKst = new TableColumn(tableWater, SWT.NONE);
columnKst.setText("Kst-Value");
TableColumn columnKstBl = new TableColumn(tableWater, SWT.NONE);
columnKstBl.setText("Kst-Block");
for(int i = 0; i < 27; ++i) {
TableItem item = new TableItem(tableWater, SWT.NULL);
for(int j = 0; j < 3; ++j) {
item.setText(j, "Item " + i + "-" + j);
}
}
for(int i = 0; i < 3; ++i) {
TableColumn column = tableWater.getColumn(i);
column.pack();
}
tableWater.pack();
sc1.setContent(tableWater);
GridData gridData1 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
gridData1.heightHint = 400;
sc1.setLayoutData(gridData1);
-----------------------8<--------------------------

The "gridData1.heighHint = 400;" does the trick. :-)

Martin
Previous Topic:Changing UI Orientation
Next Topic:Resize Table in a (Scrolled)Composite
Goto Forum:
  


Current Time: Sun Sep 20 09:07:25 GMT 2020

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

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

Back to the top