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