[英]how to add padding to java swt groups
I am working on java swt. 我正在使用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. 我应该在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: 结果是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.