6.2.2. Verwendung der nativen UI Referenz unter Swt

Das JoToSwtSnipped demonstriert die Verwendung der nativen Swt UI Referenz in einer jowidgets Applikation:

  1  package org.jowidgets.examples.swt.snipped;
  2  
  3  import org.eclipse.swt.SWT;
  4  import org.eclipse.swt.browser.Browser;
  5  import org.eclipse.swt.widgets.Composite;
  6  import org.jowidgets.api.layout.FillLayout;
  7  import org.jowidgets.api.toolkit.Toolkit;
  8  import org.jowidgets.api.widgets.IComposite;
  9  import org.jowidgets.api.widgets.IFrame;
 10  import org.jowidgets.common.application.IApplication;
 11  import org.jowidgets.common.application.IApplicationLifecycle;
 12  import org.jowidgets.tools.widgets.blueprint.BPF;
 13  
 14  public final class JoToSwtSnipped implements IApplication {
 15  
 16      @Override
 17      public void start(final IApplicationLifecycle lifecycle) {
 18          //create the root frame
 19          final IFrame frame = Toolkit.createRootFrame(BPF.frame("JoToSwt Snipped"), lifecycle);
 20          frame.setSize(1024, 768);
 21          frame.setLayout(FillLayout.get());
 22  
 23          //create a regular jo composite
 24          final IComposite joComposite = frame.add(BPF.composite());
 25  
 26          //get the native ui reference which must be a swt composite
 27          //because swt SPI impl is used
 28          final Composite swtComposite = (Composite) joComposite.getUiReference();
 29          swtComposite.setLayout(new org.eclipse.swt.layout.FillLayout());
 30  
 31          //create a swt browser
 32          final Browser browser = new Browser(swtComposite, SWT.NONE);
 33          browser.setUrl("http://www.jowidgets.org/");
 34  
 35          //set the root frame visible
 36          frame.setVisible(true);
 37      }
 38  
 39      public static void main(final String[] args) throws Exception {
 40          Toolkit.getApplicationRunner().run(new JoToSwtSnipped());
 41          System.exit(0);
 42      }
 43  }

Siehe auch PDF Version dieses Dokuments, Jowidgets API Spezifikation