comparison snippets/combo/Snippet269.d @ 119:9a1be6ff19a2

More snippets, thanks to Tom D.
author Frank Benoit <benoit@tionex.de>
date Sun, 20 Jul 2008 15:26:06 +0200
parents
children
comparison
equal deleted inserted replaced
118:7b1c122b4128 119:9a1be6ff19a2
1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html37
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 * D Port:
11 * Thomas Demmer <t_demmer AT web DOT de>
12 *******************************************************************************/
13 module combo.Snippet269;
14
15 /*
16 * Combo example snippet: set the caret position within a Combo's text
17 *
18 * For a list of all SWT example snippets see
19 * http://www.eclipse.org/swt/snippets/
20 */
21 import dwt.DWT;
22 import dwt.widgets.Combo;
23 import dwt.widgets.Display;
24 import dwt.widgets.Shell;
25 import dwt.graphics.Point;
26 import dwt.layout.FillLayout;
27
28 import dwt.dwthelper.utils;
29
30 void main(String[] args) {
31 Display display = new Display ();
32 Shell shell = new Shell (display);
33 shell.setLayout (new FillLayout ());
34 Combo combo = new Combo (shell, DWT.NONE);
35 combo.add ("item");
36 combo.select (0);
37 shell.pack ();
38 shell.open ();
39 int stringLength = combo.getText().length;
40 combo.setSelection (new Point (stringLength, stringLength));
41 while (!shell.isDisposed ()) {
42 if (!display.readAndDispatch ()) display.sleep ();
43 }
44 display.dispose ();
45 }