[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[platform-swt-dev] Table fullsize + first ToolItem always enabled
|
Hello list,
I'm having a problem with the Table class: it isn't shown in fullsize.
I've searched through the archive of this list, but I couldn't find any
usefull answer so far.
I think the best way to describe the error is by showing a screenshot:
http://www.clueless.be/Pics/swt-table.jpg. Below is my code:
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.graphics.*;
public class Test {
public static void main(String args[]) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setMaximized(true);
shell.setText("Planner");
GridLayout gridLayout = new GridLayout();
gridLayout.verticalSpacing = 0;
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
gridLayout.horizontalSpacing = 0;
shell.setLayout(gridLayout);
// ------------------
ToolItem toolItem = null;
CoolBar coolBar = new CoolBar(shell, SWT.NONE);
coolBar.setLayoutData(new GridData());
ToolBar toolBar = new ToolBar(coolBar, SWT.FLAT);
toolItem = new ToolItem(toolBar, SWT.PUSH);
toolItem.setText("New Route");
toolItem.setToolTipText("New Route");
toolItem = new ToolItem(toolBar, SWT.PUSH);
toolItem.setText("Save Current Route");
toolItem.setToolTipText("Save Current Route");
toolItem = new ToolItem(toolBar, SWT.PUSH);
toolItem.setText("Open Saved Route");
toolItem.setToolTipText("Open Saved Route");
CoolItem coolItem = new CoolItem(coolBar, SWT.NULL);
coolItem.setControl(toolBar);
Point size = toolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Point coolSize = coolItem.computeSize(size.x, size.y);
coolItem.setSize(coolSize);
// ------------------
Table table = new Table(shell, SWT.SINGLE);
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn tableColumn = null;
tableColumn = new TableColumn(table, SWT.LEFT);
tableColumn.setText("Step");
tableColumn.setWidth(40);
tableColumn = new TableColumn(table, SWT.LEFT);
tableColumn.setText("Description");
tableColumn.setWidth(80);
tableColumn = new TableColumn(table, SWT.LEFT);
tableColumn.setText("Distance");
tableColumn.setWidth(80);
tableColumn = new TableColumn(table, SWT.LEFT);
tableColumn.setText("Time");
tableColumn.setWidth(80);
TableItem item1 = new TableItem(table, 0);
item1.setText(new String[] { "a", "b" });
...
// ------------------
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
And what is the reason the first ToolItem (the button with 'New Route'
in this case) always being enabled?
I'm still new to SWT programming, so please keep it simple ;)
Thanks a lot for your time!
--
Peter