Simple SWT Table [message #633050] |
Fri, 15 October 2010 08:25 |
Andrea Messages: 7 Registered: October 2010 |
Junior Member |
|
|
Hi,
I'm a new user of SWT. I have a problem:
I have edited a simple snippets file
package swtsnippets;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.TableEditor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
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 ParkedTable {
static Image image;
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
Table table = new Table(shell, SWT.MULTI | SWT.BORDER
| SWT.FULL_SELECTION);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
data.heightHint = 200;
table.setLayoutData(data);
table.setLinesVisible(true);
table.setHeaderVisible(true);
image = new Image(display, "C:\\antenna.png");
createColumns(table);
setData(table);
resizeColumns(table);
shell.pack ();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
private static void resizeColumns(Table table) {
for (int i=1; i<4; i++) {
table.getColumn (i).pack ();
table.getColumn(2).setAlignment(SWT.CENTER);
System.out.println(table.getHeaderHeight());
}
}
private static void setData(Table table) {
for (int i=0; i<12; i++) {
TableItem item = new TableItem (table, SWT.NONE);
item.setText (0, "0x0000");
item.setText (1, "0x466467-0x466ef7");
Button b = new Button(table, SWT.CHECK | SWT.CENTER);
TableEditor editor = new TableEditor (table);
editor.grabHorizontal = editor.grabVertical = true;
editor.setEditor (b, item, 2);
b = new Button(table, SWT.CHECK | SWT.RESIZE);
editor = new TableEditor (table);
editor.grabHorizontal = editor.grabVertical = true;
editor.setEditor (b, item, 3);
}
}
private static void createColumns(Table table) {
// Create five columns
TableColumn column = new TableColumn(table, SWT.CENTER);
column.setImage(image);
column.setWidth(50);
column = new TableColumn(table, SWT.CENTER);
column.setText("MAC Address");
column = new TableColumn(table, SWT.CENTER);
column.setText("Parked");
column = new TableColumn(table, SWT.CENTER);
column.setText("Active");
}
}
There are tree problems:
I want set the header size from 24 to 30 px
I want center checkbox button in cells...
I want change background color of some cells
Thanks.
Andrea
[Updated on: Fri, 15 October 2010 09:17] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02407 seconds