Assosciating Keyboard button with Mouse Right button
There is one problem i am facing in java swings application.
I have one JPopupMenu which is invoked when we use the right button of our mouse. But when i use the keyboard button to invoke the right click menu it does not work.
In windows envoirment the properties button which is adjacent to the windows key on the keyboard is equivalent to right click of mouse.
But why this is not workable in java AWT or Swings applications.
Does java support this or we hve to add some code to make that key workable. Or is there any way thru wich i can invoke the JPopupMenu when user press a key which has a keyCode = 525 .
Plz reply me as soon as possible.
Thanks in advance.
You should be able to show it whenever you want to. If you can have a listener respond to that key then you should be able to do something like:
There should be a way to get the coordinates of the mouse at any given time, but I'm not entirely positive how you do it.
popup.show(e.getSource(), left, top);
Hope this helps.
Thnks evlich for ur response....
but there is one way tht i want tell u is to use InputMap if some one wants to generate popup menu on pressing ctrl + spacebar.
InputMap map = panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
panel.getActionMap().put( "postMenuAction", new ActivatePopupMenuAction(this,treePopupMenu));
i hve tried even this but this sucks. As my application is extending JFrame and JFrame has no getInputMap() or getActionMap().
So this will run fine if u hve some application extending JPanel.
Now what i hve to done to open Popup menu is that I implemented KeyListener interface and in keypressed method i inserted ur code which works absolutely fines.
Well Thnks for ur reply
By Andrew in forum VB Classic
Last Post: 06-25-2009, 11:55 PM
By fulcanelli in forum Java
Last Post: 11-06-2005, 03:29 PM
By me_code2004 in forum VB Classic
Last Post: 09-11-2005, 03:02 AM
By DrunkinP in forum Java
Last Post: 03-31-2005, 10:36 AM
By cinderella in forum Java
Last Post: 03-03-2005, 04:23 PM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center