createPartControl(Composite parent) { Composite embed = new Composite(parent, SWT.EMBEDDED | SWT.DOUBLE_BUFFERED); Frame frame = SWT_AWT.new_Frame(embed); JApplet japp = new JApplet(); JMap jmap = new JMap(); jmap.setDoubleBuffering(true); // add layers to map ... frame.add(japp); japp.add(jmap); }
import org.eclipse.swt.widgets.Text; import com.esri.client.toolkit.overlays.DrawingOverlay; import com.esri.client.toolkit.overlays.DrawingOverlay.DrawingMode; import com.esri.core.symbol.SimpleFillSymbol; import com.esri.core.symbol.SimpleLineSymbol; import com.esri.map.ArcGISTiledMapServiceLayer; import com.esri.map.JMap; import com.esri.runtime.ArcGISRuntime; import com.esri.runtime.ArcGISRuntime.RenderEngine; public class SWTJMapTest { public static void main(String[] args) throws InvocationTargetException, InterruptedException { ArcGISRuntime.setRenderEngine(RenderEngine.OpenGL); final Display display = new Display(); Shell shell = new Shell(display); Composite comp = new Composite(shell, SWT.EMBEDDED | SWT.NO_BACKGROUND); comp.setBounds(5, 5, 500, 500); final java.awt.Frame frame = SWT_AWT.new_Frame(comp); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { JMap map = new JMap(); ArcGISTiledMapServiceLayer tiledLayer = new ArcGISTiledMapServiceLayer( "http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer"); map.getLayers().add(tiledLayer); DrawingOverlay drawing = new DrawingOverlay(); drawing.setUp(DrawingMode.POLYLINE_RECTANGLE, new SimpleLineSymbol(Color.red, 2.0f), null); map.addMapOverlay(drawing); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(map, BorderLayout.CENTER); frame.add(panel); // no flicker //frame.add(map); // flickers } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }