KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > jemacs > swt > CommandDialog


1 //This is free software; for terms and warranty disclaimer see ./COPYING.
2

3 package gnu.jemacs.swt;
4
5 import org.eclipse.swt.SWT;
6 import org.eclipse.swt.widgets.Dialog;
7 import org.eclipse.swt.widgets.Display;
8 import org.eclipse.swt.widgets.Shell;
9
10 /**
11  * @author Christian Surlykke
12  * 28-07-2004
13  */

14 public class CommandDialog extends Dialog
15 {
16
17   /**
18    * @param parent
19    */

20   public CommandDialog(Shell parent)
21   {
22     super(parent);
23   }
24
25   /**
26    * @param parent
27    * @param style
28    */

29   public CommandDialog(Shell parent, int style)
30   {
31     super(parent, style);
32   }
33
34   public String JavaDoc getCommand() {
35     Shell parent = getParent();
36     Shell shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
37     shell.setText(getText());
38     // Your code goes here (widget creation, set result, etc).
39
shell.open();
40     Display display = parent.getDisplay();
41     while (!shell.isDisposed()) {
42       if (!display.readAndDispatch()) display.sleep();
43     }
44     return "hejsa";
45   }
46 }
47
Popular Tags