3.8.2. Dialog

Die Klasse Dialog ist wie folgt implementiert:

  1  public class Dialog extends FrameWrapper implements IFrame {
  2  
  3      public Dialog(final IWindow parent, final String title, final IImageConstant icon) {
  4          this(parent, BPF.dialog(title).setIcon(icon));
  5      }
  6  
  7      public Dialog(final IWindow parent, final String title) {
  8          this(parent, BPF.dialog(title));
  9      }
 10      
 11      public Dialog(final IWindow parent, final IWidgetDescriptor<? extends IFrame> descriptor) {
 12          super(Toolkit.getWidgetFactory().create(
 13              Assert.getParamNotNull(parent, "parent").getUiReference(), 
 14              descriptor));
 15      }
 16  
 17      protected IFrame getFrame() {
 18          return (IFrame) super.getWidget();
 19      }
 20  }

Das BaseDialogSnipped demonstriert die Verwendung der Klasse Dialog:

  1  public final class BaseDialogSnipped implements IApplication {
  2  
  3      @Override
  4      public void start(final IApplicationLifecycle lifecycle) {
  5  
  6          //create the root frame
  7          final IFrameBluePrint frameBp = BPF.frame().setTitle("Base dialog Snipped");
  8          frameBp.setSize(new Dimension(300, 200));
  9          final IFrame frame = Toolkit.createRootFrame(frameBp, lifecycle);
 10          frame.setLayout(new MigLayoutDescriptor("[]", "[]"));
 11  
 12          //create a dialog
 13          final IFrame dialog = new MyDialog(frame);
 14  
 15          //create a button that opens the dialog
 16          final IButton button = frame.add(BPF.button("Open dialog"));
 17          button.addActionListener(new IActionListener() {
 18              @Override
 19              public void actionPerformed() {
 20                  dialog.setVisible(true);
 21              }
 22          });
 23  
 24          //set the frame visible
 25          frame.setVisible(true);
 26      }
 27  
 28      private final class MyDialog extends Dialog {
 29  
 30          public MyDialog(final IWindow parent) {
 31              super(parent, "My Dialog");
 32  
 33              setMinPackSize(new Dimension(300, 0));
 34  
 35              setLayout(new MigLayoutDescriptor("wrap", "[][grow]", "[][]"));
 36  
 37              add(BPF.textLabel("Label 1"));
 38              add(BPF.inputFieldString(), "growx");
 39  
 40              add(BPF.textLabel("Label 2"));
 41              add(BPF.inputFieldString(), "growx");
 42          }
 43          
 44      }
 45  }

Siehe auch PDF Version dieses Dokuments, Jowidgets API Spezifikation