TableLayout sizing a little weird [message #150516] |
Wed, 29 October 2003 00:27  |
Eclipse User |
|
|
|
Originally posted by: sunblaze.sympatico.ca
I'm not all too clear on how the TableLayout is suppose to format the
columns in a Table. I've tried setting the weight of the columns using
ColumnWeightData but I haven't got very good results. I expected the columns
to fill the size of the table but instead it packs everything together to
try to take up as little space as possible. Is there any nice ways of making
the columns span the space nicely by default?
Here's some code snippets of what I did.
private String[] columnHeaders = { "Server",
"Something",
"Info"
};
private ColumnLayoutData[] columnLayouts = {
new ColumnWeightData(20,200),
new ColumnWeightData(10,100),
new ColumnWeightData(10,100)
};
private void createColumns() {
TableLayout layout = new TableLayout();
table.setLayout(layout);
table.setHeaderVisible(true);
for (int i = 0; i < columnHeaders.length; i++) {
TableColumn tc = new TableColumn(table, SWT.NONE, i);
tc.setText(columnHeaders[i]);
tc.setResizable(columnLayouts[i].resizable);
layout.addColumnData(columnLayouts[i]);
//TODO add a listener for header sorting
//tc.addSelectionListener(headerListener);
}
}
Any suggestions would be appreciated...
Thanks,
James
|
|
|
Re: TableLayout sizing a little weird [message #150784 is a reply to message #150516] |
Wed, 29 October 2003 11:10   |
Eclipse User |
|
|
|
If you are talking about table primary column layout, it works OK. The
problem appears when you resize table (at least for Eclipse up to
version 2.1.1): it doesn't want to resize column using specified
weights. That's because TableLayout works only one time. Comment in
TableLayout class (if I remember it right) says that it was done on
purpose to avoid some flickering problems. To solve this problem I use
resize table listener for the table which modifies column sizes using
TableColumn.setWidth() method on the base of their weights.
Sunblaze wrote:
> I'm not all too clear on how the TableLayout is suppose to format the
> columns in a Table. I've tried setting the weight of the columns using
> ColumnWeightData but I haven't got very good results. I expected the columns
> to fill the size of the table but instead it packs everything together to
> try to take up as little space as possible. Is there any nice ways of making
> the columns span the space nicely by default?
>
> Here's some code snippets of what I did.
>
>
> private String[] columnHeaders = { "Server",
>
> "Something",
>
> "Info"
>
> };
>
> private ColumnLayoutData[] columnLayouts = {
>
> new ColumnWeightData(20,200),
>
> new ColumnWeightData(10,100),
>
> new ColumnWeightData(10,100)
>
> };
>
> private void createColumns() {
>
> TableLayout layout = new TableLayout();
>
> table.setLayout(layout);
>
> table.setHeaderVisible(true);
>
> for (int i = 0; i < columnHeaders.length; i++) {
>
> TableColumn tc = new TableColumn(table, SWT.NONE, i);
>
> tc.setText(columnHeaders[i]);
>
> tc.setResizable(columnLayouts[i].resizable);
>
> layout.addColumnData(columnLayouts[i]);
>
>
> //TODO add a listener for header sorting
>
> //tc.addSelectionListener(headerListener);
>
> }
>
> }
>
> Any suggestions would be appreciated...
>
> Thanks,
>
> James
>
>
|
|
|
Re: TableLayout sizing a little weird [message #151318 is a reply to message #150784] |
Wed, 29 October 2003 23:26  |
Eclipse User |
|
|
|
Originally posted by: sunblaze.sympatico.ca
Ok, well I'm using Eclipse 3.0 if that matters. And I'm manualy setting the
column widths using setWidth upon creation now. I just thought the whole
point of the TableLayout was to at least do that for you. Oh well, and
thanks for the tip about listening for resizing that should help me get the
proper effect.
"Alex Chapiro" <achapiro@qnx.com> wrote in message
news:bnontt$l2e$1@eclipse.org...
> If you are talking about table primary column layout, it works OK. The
> problem appears when you resize table (at least for Eclipse up to
> version 2.1.1): it doesn't want to resize column using specified
> weights. That's because TableLayout works only one time. Comment in
> TableLayout class (if I remember it right) says that it was done on
> purpose to avoid some flickering problems. To solve this problem I use
> resize table listener for the table which modifies column sizes using
> TableColumn.setWidth() method on the base of their weights.
>
> Sunblaze wrote:
> > I'm not all too clear on how the TableLayout is suppose to format the
> > columns in a Table. I've tried setting the weight of the columns using
> > ColumnWeightData but I haven't got very good results. I expected the
columns
> > to fill the size of the table but instead it packs everything together
to
> > try to take up as little space as possible. Is there any nice ways of
making
> > the columns span the space nicely by default?
> >
> > Here's some code snippets of what I did.
> >
> >
> > private String[] columnHeaders = { "Server",
> >
> > "Something",
> >
> > "Info"
> >
> > };
> >
> > private ColumnLayoutData[] columnLayouts = {
> >
> > new ColumnWeightData(20,200),
> >
> > new ColumnWeightData(10,100),
> >
> > new ColumnWeightData(10,100)
> >
> > };
> >
> > private void createColumns() {
> >
> > TableLayout layout = new TableLayout();
> >
> > table.setLayout(layout);
> >
> > table.setHeaderVisible(true);
> >
> > for (int i = 0; i < columnHeaders.length; i++) {
> >
> > TableColumn tc = new TableColumn(table, SWT.NONE, i);
> >
> > tc.setText(columnHeaders[i]);
> >
> > tc.setResizable(columnLayouts[i].resizable);
> >
> > layout.addColumnData(columnLayouts[i]);
> >
> >
> > //TODO add a listener for header sorting
> >
> > //tc.addSelectionListener(headerListener);
> >
> > }
> >
> > }
> >
> > Any suggestions would be appreciated...
> >
> > Thanks,
> >
> > James
> >
> >
|
|
|
Powered by
FUDForum. Page generated in 0.07194 seconds