2015-07-21 110 views
0

我正在使用java swt。我想在組內添加填充,我嘗試瞭如下所示。如何添加填充到java swt組

excelFileGroup = factory.createGroup(container, "Destination"); 
    FormLayout excelFileGroupLayout = new FormLayout(); 
    excelFileGroupLayout.marginBottom = 50; 
    excelFileGroupLayout.marginTop = 10; 
    excelFileGroupLayout.marginLeft = 10; 
    excelFileGroupLayout.marginRight = 10; 
    excelFileGroup.setLayout(excelFileGroupLayout); 

即使嘗試此操作後,我也沒有填充。有沒有其他方式,或者我用不正當方式使用它。

我應該在LayoutData中添加填充嗎?如果是的話那麼如何?

感謝您的幫助。

+1

你需要向我們展示一個更完整的例子,你在做什麼 –

+0

我想添加組內的填充 –

回答

0

目前還不清楚你所要求的或您的具體要求是什麼什麼,但我能使用避過一組的內容填充如下:

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

} 

導致:

enter image description here