comparison org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet44.d @ 28:69b1fa94a4a8

Added SWT snippets
author Frank Benoit <benoit@tionex.de>
date Sun, 22 Mar 2009 15:17:04 +0100
parents
children 0a55d2d5a946
comparison
equal deleted inserted replaced
27:1bf55a6eb092 28:69b1fa94a4a8
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.html
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 org.eclipse.swt.snippets.Snippet44;
14
15 /*
16 * Cursor example snippet: set the hand cursor into a control
17 *
18 * For a list of all SWT example snippets see
19 * http://www.eclipse.org/swt/snippets/
20 */
21 import org.eclipse.swt.SWT;
22 import org.eclipse.swt.graphics.Cursor;
23 import org.eclipse.swt.widgets.Button;
24 import org.eclipse.swt.widgets.Display;
25 import org.eclipse.swt.widgets.Event;
26 import org.eclipse.swt.widgets.Listener;
27 import org.eclipse.swt.widgets.Shell;
28
29 import java.lang.all;
30
31 void main (String [] args) {
32 Display display = new Display ();
33 Cursor cursor = new Cursor (display, SWT.CURSOR_HAND);
34 Shell shell = new Shell (display);
35 shell.open ();
36 Button b = new Button (shell, 0);
37 b.setBounds (10, 10, 200, 200);
38 b.addListener (SWT.Selection, new class() Listener{
39 public void handleEvent (Event e) {
40 b.setCursor (cursor);
41 }
42 });
43 while (!shell.isDisposed ()) {
44 if (!display.readAndDispatch ()) display.sleep ();
45 }
46 cursor.dispose ();
47 display.dispose ();
48 }
49