SWT制作下拉式toolbar菜单按钮的代码片段

发表于:2007-07-01来源:作者:点击数: 标签:
SWT制作下拉式toolbar菜单按钮的代码片段:final ToolItem dropdown = new ToolItem(bar, SWT.DROP_DOWN);dropdown.setText(Drop-down);//一个popoupMenufinal Menu menu = new Menu(shell, SWT.POP_UP);MenuItem choice = new MenuItem(menu, SWT.PUSH);choic
SWT制作下拉式toolbar菜单按钮的代码片段:final ToolItem dropdown = new ToolItem(bar, SWT.DROP_DOWN);dropdown.setText("Drop-down");//一个popoupMenufinal 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://www.ltesting.net