Community
Participate
Working Groups
Eclipse build id or SWT version: swt version 3.1.2 Platform(s) tested on: windows xp Snippet title: create a dialog shell with upper left corner at cursor position Snippet code: /******************************************************************************* * Copyright (c) 2000, 2004 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.swt.snippets; /* * Shell example snippet: create a dialog shell with upper left corner * at cursor position * * For a list of all SWT example snippets see * http://www.eclipse.org/swt/snippets/ */ import org.eclipse.swt.*; import org.eclipse.swt.widgets.*; public class Snippet1{ public static void main (String [] args) { final Display display = new Display (); final Shell shell = new Shell (display); shell.setText ("Shell"); shell.setSize (400, 400); shell.setText("Parent form"); shell.open (); shell.addMouseListener(new org.eclipse.swt.events.MouseAdapter() { public void mouseDown(org.eclipse.swt.events.MouseEvent e) { Shell dialog = new Shell (shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); dialog.setLocation(display.getCursorLocation().x, display.getCursorLocation().y); dialog.setText ("Dialog form"); dialog.setSize (100, 100); dialog.open (); }}); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); } }
sorry for my bad English :-)!!!
CAR, please evaluate this snippet, fix as necessary (get rid of multiple calls to getCursorLocation()) and post it. Should this snippet just be "position a shell"?
Done. Check out Snippet233.