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();
}
}
|