I am working on java swt. I wanted to add padding inside a group and I have tried as shown below.
excelFileGroup = factory.createGroup(container, "Destination");
FormLayout excelFileGroupLayout = new FormLayout();
excelFileGroupLayout.marginBottom = 50;
excelFileGroupLayout.marginTop = 10;
excelFileGroupLayout.marginLeft = 10;
excelFileGroupLayout.marginRight = 10;
excelFileGroup.setLayout(excelFileGroupLayout);
Even after trying this I get no padding. Is there any other way or I have just used it in improper way.
Should I add padding in the LayoutData. If so then how?
Thanks for helping.
It's unclear exactly what you are asking for or what your specific requirements are, but I am able to getting padding around the contents of a group using the following:
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
public class GroupPadding extends Composite
{
public GroupPadding(Shell parent, int style)
{
super(parent, style);
this.setLayout(new FillLayout());
// Group color (white)
Color groupColor = new Color(parent.getDisplay(), new RGB(255, 255, 255));
// Group content color (grey)
Color groupContentColor = new Color(parent.getDisplay(), new RGB(100, 100, 100));
Group g = new Group(this, SWT.NONE);
g.setText("My group");
FillLayout fl = new FillLayout();
fl.marginHeight = 20;
fl.marginWidth = 20;
g.setLayout(fl);
g.setBackground(groupColor);
Composite c = new Composite(g, SWT.NONE);
c.setBackground(groupContentColor);
}
}
Which results in:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.