2
A
回答
3
SWT有一個叫酷工具欄組件,您可以通過使用 CoolBarManager很容易地創建CoolBars,或者您也可以手動使用只是其中(API Doc)
3
萬一有人發現了這個問題,我已經準備了小例子。我的問題是錯誤地使用add
方法。您必須使用add(IToolBarManager toolBarManager)
方法CoolBarManager
不是基類ContributionManager
中的一種。
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.CoolBarManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class App extends ApplicationWindow {
public App(Shell parent) {
super(parent);
}
@Override
protected Control createContents(Composite parent) {
getShell().setText("CoolBarManager example");
return super.createContents(parent);
}
@Override
public void create() {
addCoolBar(SWT.FLAT);
super.create();
}
@Override
protected CoolBarManager createCoolBarManager(int style) {
CoolBarManager cbm = new CoolBarManager(style);
IToolBarManager tb1 = new ToolBarManager(style);
IToolBarManager tb2 = new ToolBarManager(style);
tb1.add(new Action() {
{
setText("&Button1");
}
});
tb1.add(new Action() {
{
setText("&Button2");
}
});
tb1.add(new Action() {
{
setText("&Button3");
}
});
tb2.add(new Action() {
{
setText("&Button4");
}
});
tb2.add(new Action() {
{
setText("&Button5");
}
});
cbm.add(tb1);
cbm.add(tb2);
return cbm;
}
public static void main(String[] args) {
App app = new App(null);
app.setBlockOnOpen(true);
app.open();
Display.getCurrent().dispose();
}
}
相關問題
- 1. 工具欄vs appcompat v7-21工具欄
- 2. 工具欄?
- 3. 在工具欄
- 4. 工具欄onBackPressed
- 5. tinymce工具欄
- 6. 下工具欄
- 7. NavigationController +工具欄
- 8. 摺疊工具欄 - 狀態欄下的工具欄
- 9. 使用工具欄
- 10. BarButtonItem On工具欄
- 11. Java RCP工具欄
- 12. 動畫工具欄
- 13. Android工具欄:Light.DarkActionBar
- 14. 爲MD-工具欄
- 15. 工具欄上移
- 16. 工具欄出錯
- 17. 造型工具欄
- 18. Phonegap IOS工具欄
- 19. 補充工具欄
- 20. 拖動工具欄
- 21. 隱藏工具欄
- 22. 禁用工具欄?
- 23. 隱藏工具欄
- 24. 工具欄中IContributionItem
- 25. 工具欄addView不工作
- 26. 工具欄工具 - 位圖切換
- 27. XUL工具欄不在FF工具欄列表中
- 28. 添加工具欄項目上默認的工具欄
- 29. 在該工具欄的JavaScript內顯示FireFox工具欄
- 30. 添加工具欄項目或按鈕DetailViewController工具欄的iPad
嗨,謝謝你建議'CoolBar' /'CoolBarManager',但我無法得到這個工作。你可以用'CoolBar'發佈一個簡單的'ApplicationWindow'的例子,或者鏈接如何使用它的好例子嗎? – 2011-03-20 15:38:17