2012-12-25 45 views
0

鑑於從Eclipse View給我的默認容器,我希望定位AWT框架和SWT標籤。我希望SWT標籤位於頂部,而AWT框架位於它的正下方。出於某種原因,我無法讓SWT標籤畫在框架之外。我希望它們是分開的,但RowLayout似乎並沒有將組件放入隔離的行中。如何在eclipse插件中定位組件?

SWT標籤不希望被放置在AWT框架內: enter image description here

插件的視圖中的代碼:

public void createPartControl(Composite parent) { 

    container = new Composite(parent, SWT.EMBEDDED | SWT.NO_BACKGROUND); 
    RowLayout rowLayout = new RowLayout(); 
    //I have tried toggling many of the RowLayout properties but this has no effect on placing the label outside of the AWT Frame. 
    container.setLayout(rowLayout); 

    Label topLabel = new Label(container, SWT.NONE); 
    topLabel.setText("MY NEW LABEL"); 

    frame = org.eclipse.swt.awt.SWT_AWT.new_Frame(container); 
    frame.setFocusable(true); 
    frame.setFocusableWindowState(true); 

回答

2

RowLayout從未把組件集成到單獨的行,將它們放入一個排。您可以使用SWT.VERTICAL樣式創建它,以便該行從上到下而不是從左到右。但是,截圖仍然不正確。將框架作爲自己的複合材料的唯一孩子可能會有所幫助:

container = new Composite(parent, SWT.NONE); 
RowLayout rowLayout = new RowLayout(SWT.VERTICAL); 
container.setLayout(rowLayout); 

Label topLabel = new Label(container, SWT.NONE); 
topLabel.setText("MY NEW LABEL"); 

Composite frameContainer = new Composite(container, SWT.EMBEDDED | SWT.NO_BACKGROUND); 
frame = org.eclipse.swt.awt.SWT_AWT.new_Frame(frameContainer); 
frame.setFocusable(true); 
frame.setFocusableWindowState(true);