Embeded Swing/AWT components to SWT : SWT AWT Swing « SWT « Java Tutorial






Embeded Swing/AWT components to SWT
import javax.swing.JScrollPane;
import javax.swing.JTree;

import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class EmbedSwingAWTSWT {
  public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("SWT and Swing/AWT Example");

    Composite treeComp = new Composite(shell, SWT.EMBEDDED); 

    treeComp.setBounds(5,5,300,300);
    
    java.awt.Frame fileTableFrame = SWT_AWT.new_Frame(treeComp);
    java.awt.Panel panel = new java.awt.Panel(new java.awt.BorderLayout());
    fileTableFrame.add(panel);
    JTree fileTable = new JTree();
    fileTable.setDoubleBuffered(true);
    JScrollPane scrollPane = new JScrollPane(fileTable);
    panel.add(scrollPane);

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    display.dispose();
  }
}








17.118.SWT AWT Swing
17.118.1.Embeded Swing/AWT components to SWTEmbeded Swing/AWT components to SWT
17.118.2.Using AWT to paint inside SWTUsing AWT to paint inside SWT
17.118.3.Embed a JTable in SWT (no flicker)Embed a JTable in SWT (no flicker)
17.118.4.Create a FontData object which encapsulate the essential data to create a swt font.
17.118.5.Create an awt font by converting as much information as possible from the provided swt Font.
17.118.6.Create an awt font by converting as much information as possible from the provided swt FontData.
17.118.7.Creates a swt color instance to match the rgb values of the specified awt color. alpha channel is not supported.
17.118.8.Creates a swt color instance to match the rgb values of the specified awt paint.
17.118.9.Creates an AWT MouseEvent from a swt event.
17.118.10.Creates an awt color instance to match the rgb values of the specified swt color.
17.118.11.Draw Graphics2D stuff on a swt composite
17.118.12.Returns an AWT point with the same coordinates as the specified SWT point.
17.118.13.Returns an SWT point with the same coordinates as the specified AWT point (rounded to integer values).
17.118.14.Returns an SWT point with the same coordinates as the specified AWT point.
17.118.15.Transform a swt Rectangle instance into an AWT Rectangle.
17.118.16.Transform an awt Rectangle2d instance into a swt Rectangle2d.