Take the 2-minute tour ×

I'm having trouble embedding Swing components inside SWT (such as eclipse plugin..) Currently what I have:

 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");

This code snippet fails to load, the plugin crashes on the first line...

Any idea how to incorporate these components?


share|improve this question
add comment

2 Answers

up vote 3 down vote accepted



Frame frame = SWT_AWT.new_Frame(composite);
share|improve this answer
add comment

Since your code is failing at the first line then please first make sure that the parent Composite is created using SWT.EMBEDDED. If it is not then create a child composite using the SWT.EMBEDDED and then call

java.awt.Frame f = SWT_AWT.new_Frame(newChildComposite);


Taken from Article-Swing-SWT-Integration

share|improve this answer
add comment

Your Answer


