new MessageBox(shell, SWT.ABORT | SWT.RETRY | SWT.IGNORE)
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
public class MainClass {
public static void main(String[] a) {
Display display = new Display();
final Shell shell = new Shell(display);
MessageBox mb = new MessageBox(shell, SWT.ABORT | SWT.RETRY | SWT.IGNORE);
mb.setText("Message from SWT");
mb.setMessage("message body");
int val = mb.open();
String valString = "";
switch (val) {
case SWT.OK:
valString = "SWT.OK";
break;
case SWT.CANCEL:
valString = "SWT.CANCEL";
break;
case SWT.YES:
valString = "SWT.YES";
break;
case SWT.NO:
valString = "SWT.NO";
break;
case SWT.RETRY:
valString = "SWT.RETRY";
break;
case SWT.ABORT:
valString = "SWT.ABORT";
break;
case SWT.IGNORE:
valString = "SWT.IGNORE";
break;
}
System.out.println(valString);
shell.close();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
Related examples in the same category
1. | new MessageBox(Shell parent, int style) | | |
2. | new MessageBox(shell, SWT.OK) | | |
3. | new MessageBox(shell, SWT.OK | SWT.CANCEL) | | |
4. | new MessageBox(shell, SWT.RETRY | SWT.CANCEL) | | |
5. | new MessageBox(shell, SWT.YES | SWT.NO) | | |
6. | new MessageBox(shell, SWT.YES | SWT.NO | SWT.CANCEL) | | |
7. | new MessageBox(shell,SWT.ICON_ERROR) | | |
8. | new MessageBox(shell,SWT.ICON_QUESTION) | | |
9. | new MessageBox(shell,SWT.ICON_WARNING) | | |
10. | new MessageBox(shell,SWT.ICON_WORKING) | | |
11. | MessageBox: open() | | |
12. | MessageBox: setMessage(String mess) | | |
13. | MessageBox: setText(String text) | | |