Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Resize Table in a (Scrolled)Composite
Resize Table in a (Scrolled)Composite [message #462100] Thu, 06 October 2005 11:50 Go to next message
martin is currently offline martinFriend
Messages: 49
Registered: July 2009
Member
I'd like to see the table in a ScrolledComposite automatically resized to
the full width and height of this composite whenever the user resizes the
application window. How can I do that?

For example:

-----------------------------8<------------------------------
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.layout.*;

public class TableResizeProblem {
public static void main (String[] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new GridLayout());


new Label(shell, SWT.NONE).setText("Kilometer: ");
Text kilometer = new Text(shell, SWT.SINGLE | SWT.BORDER);
kilometer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

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);

shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
}
-----------------------------8<------------------------------

Besides that: Why do I need the tableWater.pack() to see the table in the
composite? Is there another way to do that?

Martin
Re: Resize Table in a (Scrolled)Composite [message #462103 is a reply to message #462100] Thu, 06 October 2005 13:09 Go to previous messageGo to next message
arne anka is currently offline arne ankaFriend
Messages: 133
Registered: July 2009
Senior Member
On Thu, 06 Oct 2005 13:50:42 +0200, Martin Röhricht <martin@rohrbold.de>
wrote:

> Water
Re: Resize Table in a (Scrolled)Composite [message #462104 is a reply to message #462100] Thu, 06 October 2005 13:10 Go to previous messageGo to next message
arne anka is currently offline arne ankaFriend
Messages: 133
Registered: July 2009
Senior Member
On Thu, 06 Oct 2005 13:50:42 +0200, Martin Röhricht <martin@rohrbold.de>
wrote:

> I'd like to see the table in a ScrolledComposite automatically resized to
> the full width and height of this composite whenever the user resizes the
> application window. How can I do that?
you might need to set your Scrollable
setExpandHorizontal(true);
setExpandVertical(true);

regards ("nach fest kommt ab!")
Re: Resize Table in a (Scrolled)Composite [message #462105 is a reply to message #462104] Thu, 06 October 2005 13:25 Go to previous message
martin is currently offline martinFriend
Messages: 49
Registered: July 2009
Member
arne anka wrote:
> setExpandHorizontal(true);
> setExpandVertical(true);

Perfect, that's what I was looking for. Thank you very much.

What would make it look even better would be to let the columns rearrange
their width according to the width of the composite. I doubt that there is
a automagically adjustment function, but SWT is a great framework so
maybe ...

Does anybody know of something for it?

Martin
Previous Topic:control the size of a table
Next Topic:ImageRegistry and ApplicationWindow
Goto Forum:
  


Current Time: Wed Sep 23 06:20:40 GMT 2020

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

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

Back to the top