2012-05-22 24 views
0

我想爲Eclipse編輯器設計一個窗體並運行幾個問題。表格和兩個按鈕的Eclipse佈局

這個想法是有一個頁面,其中包含2個部分 - 左手部分包含一個表和兩個按鈕。該表應該與該部分的頂部對齊並向右擴展至底部。我希望按鈕位於表格右側,每個按鈕位於另一個下方,並讓它們與桌面頂部對齊。

有沒有人知道我需要做什麼GridLayouts的設置?我嘗試了所有我能想到的運氣組合。

離我最近的第二個按鈕位於頁面底部。

這裏是我的代碼的摘錄至今: -

Section section = toolkit.createSection(sashForm, ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED | ExpandableComposite.NO_TITLE_FOCUS_BOX); 
section.setText("All Items"); 

Composite client = toolkit.createComposite(section); 
section.setClient(client); 

client.setLayout(new GridLayout(2, false)); 

Table table = toolkit.createTable(client, SWT.NULL); 
table.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); 

TableViewer viewer = new TableViewer(table); 

Button addButton = toolkit.createButton(client, "Add", SWT.PUSH); 
addButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); 

Button removeButton = toolkit.createButton(client, "Remove", SWT.PUSH); 
removeButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); 

回答

1

SWT Layout Tutorials看看它有網格佈局良好的部分。

你會想要使用表GridData.verticalSpan讓它覆蓋兩行。這應該把兩個按鈕放在右邊。但是這些按鈕會佔用與表格相同的空間,這可能不是您想要的,所以您可能需要向表格提供垂直尺寸提示。

+0

這就是傢伙!我知道這很簡單,謝謝。 – bodger