List of usage examples for javax.swing JApplet setLayout
public void setLayout(LayoutManager manager)
LayoutManager
. From source file:org.carrot2.workbench.vis.aduna.AdunaClusterMapViewPage.java
private void createAdunaControl(Composite parent) { /*/*from ww w . java2 s . com*/ * If <code>true</code>, try some dirty hacks to avoid flicker on Windows. */ final boolean windowsFlickerHack = true; if (windowsFlickerHack) { System.setProperty("sun.awt.noerasebackground", "true"); } this.scrollable = new Composite(parent, SWT.H_SCROLL | SWT.V_SCROLL); scrollable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); final GridLayout layout = new GridLayout(); layout.marginBottom = 0; layout.marginLeft = 0; layout.marginRight = 0; layout.marginTop = 0; layout.horizontalSpacing = 0; layout.verticalSpacing = 0; layout.marginHeight = 0; layout.marginWidth = 0; scrollable.setLayout(layout); embedded = new Composite(scrollable, SWT.NO_BACKGROUND | SWT.EMBEDDED); embedded.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); final Frame frame = SWT_AWT.new_Frame(embedded); frame.setLayout(new java.awt.BorderLayout()); // LINGO-446: flicker fix; see "Creating a Root Pane Container" in http://www.eclipse.org/articles/article.php?file=Article-Swing-SWT-Integration/index.html final JApplet applet = new JApplet(); frame.add(applet); applet.setLayout(new java.awt.BorderLayout()); final JScrollPane scrollPanel = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPanel.setDoubleBuffered(true); scrollPanel.setBorder(BorderFactory.createEmptyBorder()); applet.getContentPane().add(scrollPanel, java.awt.BorderLayout.CENTER); final ClusterMapFactory factory = ClusterMapFactory.createFactory(); final ClusterMap clusterMap = factory.createClusterMap(); final ClusterMapMediator mapMediator = factory.createMediator(clusterMap); this.mapMediator = mapMediator; final ClusterGraphPanel graphPanel = mapMediator.getGraphPanel(); graphPanel.setDoubleBuffered(true); scrollPanel.setViewportView(graphPanel); scrollable.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { updateScrollBars(); } }); final SelectionAdapter adapter = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ScrollBar hbar = scrollable.getHorizontalBar(); ScrollBar vbar = scrollable.getVerticalBar(); final java.awt.Rectangle viewport = new java.awt.Rectangle(hbar.getSelection(), vbar.getSelection(), hbar.getThumb(), vbar.getThumb()); SwingUtilities.invokeLater(new Runnable() { public void run() { graphPanel.scrollRectToVisible(viewport); } }); } }; scrollable.getVerticalBar().addSelectionListener(adapter); scrollable.getHorizontalBar().addSelectionListener(adapter); final Runnable updateScrollBarsAsync = new Runnable() { public void run() { updateScrollBars(); } }; graphPanel.addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { graphPanelSize = graphPanel.getPreferredSize(); Display.getDefault().asyncExec(updateScrollBarsAsync); } @Override public void componentResized(ComponentEvent e) { graphPanelSize = graphPanel.getPreferredSize(); Display.getDefault().asyncExec(updateScrollBarsAsync); } }); }