import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; public class DialogShell extends Shell { /** * Launch the application * * @param args */ public static void main(String args[]) { try { Display display = Display.getDefault(); DialogShell shell = new DialogShell(display, SWT.SHELL_TRIM); shell.open(); shell.layout(); } catch (Exception e) { e.printStackTrace(); } } /** * Create the shell * * @param display * @param style */ public DialogShell(Display display, int style) { super(display, style); createContents(); } Text text; /** * Create contents of the window */ protected void createContents() { setSize(500, 375); setText("SWT Dialog"); text = new Text(this, SWT.BORDER); text.setBounds(40, 25, 210, 30); text.setFocus(); // } @Override public void open() { // TODO Auto-generated method stub super.open(); text.setFocus(); } public void clearText() { text.setText(""); } public void setTextFocus(){ text.setFocus(); } @Override protected void checkSubclass() { // Disable the check that prevents subclassing of SWT components } }