Java by API/org.eclipse.swt.widgets/MessageBox
Содержание
- 1 MessageBox: open()
- 2 MessageBox: setMessage(String mess)
- 3 MessageBox: setText(String text)
- 4 new MessageBox(Shell parent, int style)
- 5 new MessageBox(shell, SWT.ABORT | SWT.RETRY | SWT.IGNORE)
- 6 new MessageBox(shell,SWT.ICON_ERROR)
- 7 new MessageBox(shell,SWT.ICON_QUESTION)
- 8 new MessageBox(shell,SWT.ICON_WARNING)
- 9 new MessageBox(shell,SWT.ICON_WORKING)
- 10 new MessageBox(shell, SWT.OK)
- 11 new MessageBox(shell, SWT.OK | SWT.CANCEL)
- 12 new MessageBox(shell, SWT.RETRY | SWT.CANCEL)
- 13 new MessageBox(shell, SWT.YES | SWT.NO)
- 14 new MessageBox(shell, SWT.YES | SWT.NO | SWT.CANCEL)
MessageBox: open()
<source lang="java">
import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; public class MainClass {
public static void main(String[] a) { Shell s = new Shell(); MessageBox messageBox = new MessageBox(s, SWT.ICON_QUESTION | SWT.YES | SWT.NO); messageBox.setMessage("Do you really want to exit?"); messageBox.setText("Exiting Application"); int response = messageBox.open(); if (response == SWT.YES) System.out.println(SWT.YES); else if(response == SWT.NO) System.out.println(SWT.NO); }
}
</source>
MessageBox: setMessage(String mess)
<source lang="java">
import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; public class MainClass {
public static void main(String[] a) { Shell s = new Shell(); MessageBox messageBox = new MessageBox(s, SWT.ICON_QUESTION | SWT.YES | SWT.NO); messageBox.setMessage("Do you really want to exit?"); messageBox.setText("Exiting Application"); int response = messageBox.open(); if (response == SWT.YES) System.out.println(SWT.YES); else if(response == SWT.NO) System.out.println(SWT.NO); }
}
</source>
MessageBox: setText(String text)
<source lang="java">
import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; public class MainClass {
public static void main(String[] a) { Shell s = new Shell(); MessageBox messageBox = new MessageBox(s, SWT.ICON_QUESTION | SWT.YES | SWT.NO); messageBox.setMessage("Do you really want to exit?"); messageBox.setText("Exiting Application"); int response = messageBox.open(); if (response == SWT.YES) System.out.println(SWT.YES); else if(response == SWT.NO) System.out.println(SWT.NO); }
}
</source>
new MessageBox(Shell parent, int style)
<source lang="java">
import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; public class MainClass {
public static void main(String[] a) { Shell s = new Shell(); MessageBox messageBox = new MessageBox(s, SWT.ICON_QUESTION | SWT.YES | SWT.NO); messageBox.setMessage("Do you really want to exit?"); messageBox.setText("Exiting Application"); int response = messageBox.open(); if (response == SWT.YES) System.out.println(SWT.YES); else if(response == SWT.NO) System.out.println(SWT.NO); }
}
</source>
new MessageBox(shell, SWT.ABORT | SWT.RETRY | SWT.IGNORE)
<source lang="java">
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(); }
}
</source>
new MessageBox(shell,SWT.ICON_ERROR)
<source lang="java">
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.ICON_INFORMATION); 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(); }
}
</source>
new MessageBox(shell,SWT.ICON_QUESTION)
<source lang="java">
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.ICON_QUESTION); 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(); }
}
</source>
new MessageBox(shell,SWT.ICON_WARNING)
<source lang="java">
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.ICON_WARNING); 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(); }
}
</source>
new MessageBox(shell,SWT.ICON_WORKING)
<source lang="java">
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.ICON_WORKING); 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(); }
}
</source>
new MessageBox(shell, SWT.OK)
<source lang="java">
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.OK); 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(); }
}
</source>
new MessageBox(shell, SWT.OK | SWT.CANCEL)
<source lang="java">
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.OK | SWT.CANCEL); 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(); }
}
</source>
new MessageBox(shell, SWT.RETRY | SWT.CANCEL)
<source lang="java">
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.RETRY | SWT.CANCEL); 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(); }
}
</source>
new MessageBox(shell, SWT.YES | SWT.NO)
<source lang="java">
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.YES | SWT.NO); 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(); }
}
</source>
new MessageBox(shell, SWT.YES | SWT.NO | SWT.CANCEL)
<source lang="java">
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.YES | SWT.NO | SWT.CANCEL); 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(); }
}
</source>