Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Extra row and column in a SWT Table
Extra row and column in a SWT Table [message #550348] Fri, 30 July 2010 02:08 Go to next message
Bill Masek is currently offline Bill MasekFriend
Messages: 8
Registered: July 2009
Junior Member
Hi,

I am trying to create a table without an extra row or column. I realize
that the jface TableColumnLayout can help with the column, but
I also want to eliminate that last row. Here is a snippet that shows a
simple attempt that does not work.

What do I need to do to shrink the table down to what I want? Do I need
to implement my own paint method to fix this?

Thanks
Bill Masek
781-572-8697
billmasek@comcast.net

package bill.sample;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
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 TableQuestion {

public static void addTable(Composite comp) {

Table table = new Table(comp, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
table.setHeaderVisible(true);
table.setLinesVisible(true);

for (int i = 0; i < 3; ++i) {
TableColumn tc = new TableColumn(table, SWT.NONE);
tc.setText("Column " + i);
}

for (int i = 0; i < 4; ++i) {
TableItem item = new TableItem(table, SWT.NONE);
String[] iList = new String[] { "item0-" + i, "item1-" + i,"item2-"
+ i };
item.setText(iList);
}

for (int i = 0; i < 3; ++i) {
TableColumn tc = table.getColumn(i);
tc.pack();
}

table.pack();
}

public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
RowLayout layout = new RowLayout(SWT.VERTICAL);
layout.marginHeight = 10;
layout.marginWidth = 10;
shell.setLayout(layout);

addTable(shell);
Button button = new Button(shell, SWT.PUSH);
button.setText("Try It");

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


}
Re: Extra row and column in a SWT Table [message #552290 is a reply to message #550348] Wed, 11 August 2010 15:23 Go to previous messageGo to next message
Lakshmi P ShanmugamFriend
Messages: 279
Registered: July 2009
Location: India
Senior Member
Hi,

I just came across the problem/fix. The extra space is for the scrollbars. There will be no extra space when scrollbars appear. So if you don't need scrollbars in the table you can create the Table using SWT.NO_SCROLL and remove the extra space.




Lakshmi P Shanmugam
Re: Extra row and column in a SWT Table [message #637521 is a reply to message #552290] Sat, 06 November 2010 02:04 Go to previous message
Bill Masek is currently offline Bill MasekFriend
Messages: 8
Registered: July 2009
Junior Member
On 8/11/2010 11:23 AM, Lakshmi Shanmugam wrote:
> Hi,
>
> I just came across the problem/fix. The extra space is for the
> scrollbars. There will be no extra space when scrollbars appear. So if
> you don't need scrollbars in the table you can create the Table using
> SWT.NO_SCROLL and remove the extra space.
>
>
>

Thank you. Duh, why didn't I think of that.
Previous Topic:changing background color on a table viewer depending on other view selection
Next Topic:Drag Image Across Shells
Goto Forum:
  


Current Time: Fri Apr 26 11:51:28 GMT 2024

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

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

Back to the top