[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform.swt] Expanding Column Widths to fit table

Ok, here is what I am trying to do. I have a table that I am using to fill a 
view (in RCP). I do the following to make the table fill the view:

composite.setLayout(new GridLayout(1, false));
Table t = new Table()
//populate table here
t.setLayoutData(new GridData(GridData.FILL_BOTH));

This works like a charm. Now what I want to do is use pack() on the columns 
to make sure I get the proper minimum width for each column...ok, I'm good 
to this point.

The last thing I want to do is calculate how wide the table is, determine 
how much width is not being used by the table (by subtracting the width of 
the table minus the width of the columns currently) and then re-distribute 
evenly the extra width to each column so that the end effect is that the 
table's columns fill the entire table without any empty whitespace columns. 
There is probably an easier way to do what I described, but that is why I am 
here.

This could be an RCP question just as much as SWT, because I don't 
understand the behavior yet. But if I try to acquire the table's size, it 
comes back as (0,0)...I think because it hasn't been rendered yet. If I try 
to acquire the size of the parent composite, I get the same result. How can 
I get the size of the table so that I can make these calculations (or am I 
just going about it all wrong)?

Keep in mind, this is an RCP app, so I'm trying to do this in a View class 
within the createPartControl() method...