江西广告网
标题:
SWT制作下拉式ToolBar菜单代码
[打印本页]
作者:
知足常乐
时间:
2009-2-17 10:58
标题:
SWT制作下拉式ToolBar菜单代码
SWT制作下拉式toolbar菜单按钮的代码片段: final ToolItem dropdown = new ToolItem(bar, SWT.DROP_DOWN); dropdown.setText("Drop-down"); //一个popoupMenu final Menu menu = new Menu(shell, SWT.POP_UP); MenuItem choice = new MenuItem(menu, SWT.PUSH); choice.setText("Choices"); dropdown.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { if (event.detail == SWT.ARROW) { Rectangle rect = dropdown.getBounds(); Point pt = new Point(rect.x, rect.y rect.height); pt = bar.toDisplay(pt); menu.setLocation(pt.x, pt.y); menu.setVisible(true); } } });
欢迎光临 江西广告网 (http://bbs.jxadw.com/)
Powered by Discuz! X3.2