I have some problem swing menu click event.
I want to click 'My Status' how can I handle this please help me.
For example about this image, I want to add click event for system tools.
This is a short example for my application.
List<Menu> menuItems = new ArrayList<>();
for (File file : files) {
Menu menuItem = new Menu();
menuItem.setLabel(file.getName());
menuItem.setName(file.getPath());
menuItems.add(menuItem);
menuItem.addActionListener(newMenuItemClickActions(menuItem));
}
Related
I have a plugin which adds a view. This view contains a table which contains on each row some informations. I would like to have a popup menu when I press the right mouse click.
How can I add the extension org.eclipse.ui.menus and after creating the menuContribution to see it in the view ?
In your ViewPart use this code:
MenuManager contextMenu = new MenuManager();
contextMenu.setRemoveAllWhenShown(true);
getSite().registerContextMenu(contextMenu, viewer);
Control control = viewer.getControl();
Menu menu = contextMenu.createContextMenu(control);
control.setMenu(menu);
where viewer is your TableViewer.
The context menu this creates has the same id as your view so you contribute to it with:
<menuContribution
locationURI="popup:your.view.id">
....
</menuContribution>
// TrayUtilitiesDemo is a call which is returning me tray icon create by current java process.
MyMenu.setLabel("MyMenu");
TrayUtilitiesDemo.addPopupMenu(MyMenu);
TrayIcon trayIcon = TrayUtilitiesDemo.getTrayIcon();
System.out.println("TrayIcons are: "+trayIcon);
when i am doing
trayIcon.getPopupMenu().countItems();
it is retrun only 1 menuitem. which is added by me that is MyMenu.
there are other 4 menuitems are there added by some other class which is creating this tray icon.
and not able to get the ActionListener also.
basically i want to right click on tray icon click and click on menuitem in PopupMenu added by other class(or by other process) for automation.
using windows 7 machine.
please help.
I have an SWT tray icon which I've created with the following snippet of code:
itmTrayItem = new TrayItem(trySysTray, SWT.NONE);
itmTrayItem.setToolTipText("My App");
itmTrayItem.addListener(SWT.MenuDetect, new Listener() {
public void handleEvent(Event event) {
mnuPopup.setVisible(true);
}
});
Right clicking on the tray icon brings up a context menu. I'd like to add a double-click event to the tray icon so that when the icon is double-clicked I perform some action. How can I do this?
I haven't understood how I was use the mouse listener as I've been finding some parts of the SWT docs lacking in examples.
Thanks
try the SWT.DefaultSelection event, it may do the trick
I am using RCP with eclipse 3.6 and java 6.
The user needs to click with right mouse buttom then opened a menu where he makes a choice.
Which mouse event is that?
How to fill the menu with choices?.
Regards,
Haythem
Have a look at this article about RCP and eclipse 3.6. The section that I've linked to describes how to create a context menu (for a table), that will pop up when right clicking.
What I need is how to create mouseeventlistener from a menu and menuitem
Sectionstop in my code is the composite where the mouselistener will be added
Menu menu = new Menu (parent.getShell(), SWT.POP_UP);
MenuItem item = new MenuItem (menu, SWT.PUSH);
item.setText("Text 1");
MenuItem item2 = new MenuItem (menu, SWT.PUSH);
item2.setText("text 2");
sectionStop.setMenu (menu);
Since you are on your RCP, the basic question is where does the user right clicks. Is it on your view/editor or on an object that you contributed to some viewers? A better If you then you should look into contributing via the proper extension points. Either org.eclipse.ui.popupMenus or org.eclipse.ui.menus with locationURI "popup:org.eclipse.ui.popup.any"
I want to create my own context menu.
When a user clicks the BlackBerry menu button, the menu should open with only my menu items -- and not the 'Hide keyboard' and 'Switch Application' items that are included by default.
protected void makeMenu(Menu menu, int instance) {
menu.deleteAll();
// add your code here
}
Try this out