A snippet from SWT
Jesse Phillips
jessekphillips at gmail.com
Tue Mar 4 13:36:30 PST 2008
On Tue, 04 Mar 2008 16:17:55 -0500, Ty Tower wrote:
> I'm trying to convert a snippet from SWT to DWT . I'll try to attach it
> here On my machine it does not compile . I'm using Linux . Could someone
> try it and see if it will in fact compile first . module snippet38;
>
> /*
> * Table example snippet: create a table (columns, headers, lines) *
> * For a list of all SWT example snippets see *
> http://www.eclipse.org/swt/snippets/ */
> import dwt.DWT;
> import dwt.widgets.Display;
> import dwt.widgets.Shell;
> import dwt.widgets.Table;
> import dwt.widgets.TableItem;
> import dwt.widgets.TableColumn;
>
> public class Snippet38 {
> public static void main () {
> Display display = new Display ();
> Shell shell = new Shell (display);
> Table table = new Table (shell, DWT.MULTI | DWT.BORDER |
> DWT.FULL_SELECTION ); table.setLinesVisible (true);
> table.setHeaderVisible (true);
> char[][] titles = [" "[], "C", "!", "Description", "Resource",
> "In Folder", "Location" ];
> for (int i=0; i<titles.length; i++) {
> TableColumn column = new TableColumn (table, DWT.NONE);
column.setText
> (titles [i]);
> }
> int count = 128;
> for (int i=0; i<count; i++) {
> TableItem item = new TableItem (table, DWT.NONE);
item.setText (0,
> "x");
> item.setText (1, "y");
> item.setText (2, "!");
> item.setText (3, "this stuff behaves the way I expect");
item.setText
> (4, "almost everywhere"); item.setText (5, "some.folder");
> item.setText (6, "line in nowhere" );
> }
> for (int i=0; i<titles.length; i++) {
> table.getColumn (i).pack ();
> }
> table.setSize (table.computeSize (DWT.DEFAULT, 200)); shell.pack
();
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
> }
snippet38 has already been converted.
More information about the Digitalmars-d-learn
mailing list