import org.eclipse.swt.SWT; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class ShellDefaultButton { public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Button cancelButton = new Button(shell, SWT.PUSH); cancelButton.setText("Canel"); Button rateButton = new Button(shell, SWT.PUSH); rateButton.setText("OK"); shell.setDefaultButton(rateButton); System.out.println(shell.getDefaultButton()); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } }