I have created an editable JComboBox. I want to add specific context menu but default context menu appears when right click.
Is there a way to remove it?
You can set the popup menu of the editor of the combo box by using:
ComboBoxEditor editor = comboBox.getEditor();
JTextField textField = (JTextField)editor.getEditorComponent();
textField.setComponentPopupMenu(...);
Related
How do you change the button text of FileDialog (not JFileChooser)? The two modes specify the button text:
FileDialog.LOAD -> "Open"
FileDialog.SAVE -> "Save"
But I want the button to say something else. Is it possible to change this text?
You cant change button text only with FileDialog methods, the only text you can edit in it is window's title which opens when you press for example "Open".
FileDialog fd = new FileDialog(FdExample.this, "select File", FileDialog.LOAD);
fd.setTitle("any new title");
If you want custom text in button, you can use JButton and ActionListener to activate FileDialog.
Probably this will be the best way.
FileDialog dialog = new FileDialog(Display.getDefault().getActiveShell(),SWT.SAVE);
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 use Vaadin 6.8.8. I'm trying to add action handler to panel (to get context menu). The panel takes all the place of the window, but I caused the browser context menu when i do mouse right button click.
public class MyPanel extends Panel {
public MyPanel() {
...
addActionHandler(new Action.Handler(){
...
});
setSizeFull();
}
}
What is wrong?
Those action related methods in Panel are for keyboard shorcuts. Only Tree, Table and TreeTable are the core components supporting context menu. To add a context menu to your panel, take a look at the ContextMenu add-on.
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"