将Swing组件添加到Eclipse RCP插件

Pro*_*ome 3 java swing swt eclipse-plugin

我在SWT中嵌入Swing组件时遇到了麻烦(比如eclipse插件..)目前我所拥有的:

 public void createPartControl(Composite parent) {
  java.awt.Frame f = SWT_AWT.new_Frame(parent);
  JPanel panel = new JPanel(new BorderLayout());
  JButton button = new JButton("Swing button");
  JLabel label = new JLabel("Swing label");
  panel.add(label,BorderLayout.NORTH);
  panel.add(button,BorderLayout.CENTER);
  f.add(panel);
 }
Run Code Online (Sandbox Code Playgroud)

此代码段无法加载,插件在第一行崩溃...

知道如何合并这些组件吗?

谢谢!

Wil*_*ill 5

http://www.eclipse.org/articles/article.php?file=Article-Swing-SWT-Integration/index.html

最低限度,在SWT组合内嵌入AWT帧只需两行简单的代码

Composite composite = new Composite(parent, SWT.EMBEDDED | SWT.NO_BACKGROUND);
Frame frame = SWT_AWT.new_Frame(composite);
Run Code Online (Sandbox Code Playgroud)