views:

14

answers:

3

I wanted to add a right click menu, by selecting a column in my GUI.

Any suggestions how to do it?

A: 

aha, i think what you need is to put an mouse event listener in that part of your GUI that will respond to mouse events e.g. mouse click... for the menu, what you need is a JPopupMenu... just a thought!

ultrajohn
A: 

You are talking about actions(?). Check Platform Plug-in Developer Guide > Programmer's Guide > Plugging into the workbench > Basic workbench extension points using actions.

Adi
A: 

If you're looking for solution to Tree or Table, here is an example:

    final Menu menu = new Menu(tracksTree);
    tracksTree.setMenu(menu);
    menu.addMenuListener(new MenuAdapter() {
        @Override public void menuShown(MenuEvent e) {

            MenuItem[] items = menu.getItems();
            for (int i = 0; i < items.length; i++) {
                items[i].dispose();
            }

            TreeItem[] selection = tracksTree.getSelection();
            if (selection.length > 0) {
                TreeItem selectedItem = selection[0];
                System.out.println(selectedItem.getData());


            }
        }

        @Override public void menuHidden(MenuEvent e) {

        }
    });
nanda