I am having trouble getting a simple SWT table to render correctly. Using 32bit Oracle Linux 6 it alternates background colors for the rows and makes the header a nice shade of gray and draws black vertical lines separating the columns. With the latest version of Oracle Linux 7.6, the header just has a white background. Please help me find a solution. @ewill can you help?
I have provided a picture of the 64bit table and source code below. The only dependency is swt.jar.
Thanks,
Don
/**
source code begins here
**/
package colortest;
import org.eclipse.swt.SWT;
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 colorShell extends Shell {
private Table table;
/**
* Launch the application.
* @param args
*/
public static void main(String args[]) {
try {
Display display = Display.getDefault();
colorShell shell = new colorShell(display);
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the shell.
* @param display
*
*
*
*/
public colorShell(Display display) {
super(display, SWT.SHELL_TRIM);
table = new Table(this, SWT.MULTI|SWT.BORDER | SWT.FULL_SELECTION| SWT.HIDE_SELECTION );
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn tblclmnNewColumn = new TableColumn(table, SWT.NONE);
tblclmnNewColumn.setWidth(100);
tblclmnNewColumn.setText("col1");
TableColumn tblclmnNewColumn_1 = new TableColumn(table, SWT.NONE);
tblclmnNewColumn_1.setWidth(100);
tblclmnNewColumn_1.setText("col2");
TableColumn tblclmnNewColumn_2 = new TableColumn(table, SWT.NONE);
tblclmnNewColumn_2.setWidth(100);
tblclmnNewColumn_2.setText("col3");
TableItem tableItem = new TableItem(table, SWT.NONE);
tableItem.setText("New TableItem");
TableItem tableItem_1 = new TableItem(table, SWT.NONE);
tableItem_1.setText("New TableItem");
TableItem tableItem_2 = new TableItem(table, SWT.NONE);
tableItem_2.setText("New TableItem");
table.pack();
createContents();
}
/**
* Create contents of the shell.
*/
protected void createContents() {
setText("SWT Application");
setSize(450, 300);
}
@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
}
`