import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class DialogEmptyDisplay {
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP);
final Shell dialog =new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
dialog.setLayout(new RowLayout());
dialog.pack();
dialog.open();
// Move the dialog to the center of the top level shell.
Rectangle shellBounds = shell.getBounds();
Point dialogSize = dialog.getSize();
dialog.setLocation(
shellBounds.x + (shellBounds.width - dialogSize.x) / 2,
shellBounds.y + (shellBounds.height - dialogSize.y) / 2);
// Set up the event loop.
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
// If no more entries in event queue
display.sleep();
}
}
display.dispose();
}
}
|