Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Table fullsize + first ToolItem always enabled


In order for your Table to be "big", you need to set its layout data to "fill" and "grab", perhaps something like the following:
table.setLayoutData(new GridData(GridData.FILL_BOTH));

This article on Layouts in SWT may be useful:
http://www.eclipse.org/articles/Understanding%20Layouts/Understanding%20Layouts.htm

I don't understand what you mean when you say your push button tool is enabled - perhaps you mean that it has focus?
(Use the keyboard arrow keys or tab to see that the widget that has focus is drawn differently).
Widgets are always enabled when they are created. To disable a widget, you need to send it setEnabled(false), but I don't think this is what you mean.

In future, please ask user questions on the SWT newsgroup.
Perhaps this link might have some useful info for you - it is the SWT "Getting Started" page, and it will tell you how to get to the newsgroup:
http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/platform-swt-home/SWT_Resources.html

Good luck, and welcome to SWT!

Carolyn




Peter Billen <peter@xxxxxxxxxxx>
Sent by: platform-swt-dev-admin@xxxxxxxxxxx

08/12/2004 05:54 PM

Please respond to
platform-swt-dev

To
platform-swt-dev@xxxxxxxxxxx
cc
Subject
[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
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev


Back to the top