Skip to content

Org.eclipse.swt.widgets.Control

Create a dialog shell and position it

Dialog의 위치를 변경하는 방법은 아래와 같다.

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();
  }
}

Favorite site