Mega Code Archive

 
Categories / Java Tutorial / SWT
 

Create a dialog shell and position it

import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class DialogShellPositionIt {   public static void main(String[] args) {     final Display display = new Display();     final Shell shell = new Shell(display);     Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);     Point pt = display.getCursorLocation();     dialog.setLocation(pt.x, pt.y);     dialog.setText("Dialog Shell");     dialog.setSize(100, 100);     dialog.open();     while (!shell.isDisposed()) {       if (!display.readAndDispatch())         display.sleep();     }     display.dispose();   } }