import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; /** * @author Thomas Singer */ public class TableTest { // Static ================================================================= public static void main(String[] args) { final Display display = new Display(); final Color darkGray = new Color(65, 65, 65); final Color lightGray = new Color(207, 207, 207); display.addListener(SWT.Skin, event -> { if (event.type == SWT.Skin) { if (event.widget instanceof Table) { final Table table = (Table)event.widget; table.setBackground(darkGray); table.setForeground(lightGray); table.setHeaderBackground(darkGray); table.setHeaderForeground(lightGray); } } }); final Shell shell = new Shell(display); shell.setLayout(new FillLayout(SWT.VERTICAL)); final Table table = new Table(shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL); table.setHeaderVisible(true); createColumn(SWT.LEFT, "Column 1", table); createColumn(SWT.RIGHT, "Column 2", table); createColumn(SWT.LEFT, "Column 3", table); final TableItem item = new TableItem(table, SWT.LEFT); item.setText(0, "Left"); item.setText(1, "Right"); item.setText(2, "Left"); shell.setSize(400, 500); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } private static void createColumn(int style, String text, Table table) { final TableColumn tableColumn = new TableColumn(table, style); tableColumn.setText(text); tableColumn.setMoveable(true); tableColumn.setWidth(100); } }