Search code examples
javaeclipseswinglayoutgridbaglayout

GridBagLayout in eclipse view


Dear StackOverflow readers!

I want to create eclipse plugin with new view. But when I try to set layout of parent composite which, is passed to createPartControl(Composite parent) I get "The method setLayout(Layout) in the type Composite is not applicable for the arguments (GridBagLayout)" errormessage.

How can I do that?

@Override

public void createPartControl(Composite parent) {       
    parent.setLayout(new GridBagLayout());`enter code here`
}

Thanks for the answer!


Solution

  • GridBagLayout belongs to java.awt package, whereas you are using Eclipse's SWT Composite (org.eclipse.swt.widgets). This requires a subclass of org.eclipse.swt.widgets.Layout. You will have to decide which subclass suits your needs best.