| [news.eclipse.platform.swt] Re: TableColumn pack problem |
I can't wait to get my hands on the new version.
Best regards, Robin
https://bugs.eclipse.org/bugs/show_bug.cgi?id=84077
Fixed > 20050131
"Robin Wilson" <robinwilson@xxxxxxx> wrote in message news:cteq3a$v3n$1@xxxxxxxxxxxxxxxxxx
The workaround is to create a dummy column, set the width to 0 and set resizable to false.
colLast.setWidth(0); colLast.setResizable(false);
This stops the growing problem but you still have the extra space from the vertical and horizontal scrollbars that aren't shown. I tried setting their visibility but the method call had no effect.
As I looked through SWT and JFace by Rob Warner and Robert Harris, I noticed this bug is visible in Figure 8-21 and 8-22.
If there was a way to intercept the shell layout call, the size could modified to remove the thickness of the scrollbars.
Best regards, Robin
Robin Wilson wrote:
I can probably find a workaround so I'm not dead at all. This is my first adventure with SWT so I'm really just trying to find out if my assumptions are wrong or this is a bug.
Correct behaviour or not, if reasonable usage of the API produces unexpected results, then it is either a documentation bug, a design error, or a code bug. Any way you characterize it, it's still a bug to the SWT user. From your description it sure sounds like a bug to me. No big deal, bugs happen.
I appreciate your investigation of the problem. If I can find a workaround I'll post it here.
Best regards, Robin
Steve Northover wrote:
Sigh. I've gotten to the bottom of it and have yet to decide whether it is an SWT bug or the correct (unwanted) behavior. The problem is that Column.pack() for the last column is not taking into account the space for the scroll bar. When you call shell.pack(), this eventually makes the table grow the extra space for the scroll bar ... and so on. How dead are
you?
It may be a while until I get to this again.
"Robin Wilson" <robinwilson@xxxxxxx> wrote in message news:ctbb1v$o1u$1@xxxxxxxxxxxxxxxxxx
I haven't heard from anyone yet on this. Is it a SWT bug or am I doing something wrong?
Best regards, Robin
Robin Wilson wrote:
I'm using Eclipse Version: 3.0.0 on Windows XP. This snippet illustrates another problem I'm having. The first time the table is shown, there
is
extra space after the last column that looks like it's wide enough for a scroll bar. Then as you press the button, the last column grows
everytime.
Here's my snippet:
/* * Created on Jan 24, 2005 by Robin Wilson */
import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem;
public class TableColumnProblemExample { public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Table Column Pack"); GridLayout vertical = new GridLayout(); vertical.numColumns = 1; shell.setLayout(vertical); final Table table = new Table(shell, SWT.SINGLE); table.setHeaderVisible(true); table.setLinesVisible(true); final TableColumn col1 = new TableColumn(table,SWT.CENTER); col1.setText("Column 1"); final TableColumn col2 = new TableColumn(table,SWT.CENTER); col2.setText("Column 2"); col1.pack(); col2.pack(); Button button = new Button(shell, SWT.PUSH); button.setText("Fill Data"); button.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { //table.layout(true); table.setRedraw(false); table.removeAll(); String [] data1 = { "1", "2" }; String [] data2 = { "3", "4" }; TableItem item1 = new TableItem(table, SWT.NONE); item1.setText( data1 ); TableItem item2 = new TableItem(table, SWT.NONE); item2.setText( data2 ); col1.pack(); col2.pack(); shell.pack(); table.setRedraw(true); } });
shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } }
Steve Northover wrote:
1) Which platform? 2) Post a stand alone snippet that shows the problem.
"Robin Wilson" <robinwilson@xxxxxxx> wrote in message news:cstmik$116$1@xxxxxxxxxxxxxxxxxx
The first time I create my table and pack all the columns it looks great. After, I change the contents and call pack on each column again the
last
column expands. I'm sure I must be doing something wrong. Can
someone
please
give me a hint or point me to a tutorial on tables? I've been
searching
and
searching but with no luck so far.
Thanks!