This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Show a PopupMenu using a hotkey Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Show a PopupMenu using a hotkey" Watch "Show a PopupMenu using a hotkey" New topic
Author

Show a PopupMenu using a hotkey

Mohit J Kumar
Greenhorn

Joined: Apr 08, 2010
Posts: 28

Hi all,
Is it possible to show a popup menu using a hotkey like "Alt Shift a"?
I have a table on which I am able to display a popup menu on right click.
I want to do it using some hotkey.


"It's good to B in touch...So keep responding"
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38519
    
  23
Can you add a KeyListener or similar to your table? The underlined text leads to some links which look helpful.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4531
    
    5

You can also use key bindings, which give you more flexibility than a KeyListener.
From http://download.oracle.com/javase/tutorial/uiswing/misc/keybinding.html
JComponent.WHEN_IN_FOCUSED_WINDOW
The component's window either has the focus or contains the component that has the focus. This input map is commonly used for mnemonics or accelerators, which need to be active regardless of where focus is in the window.


luck, db
There are no new questions, but there may be new answers.
 
Consider Paul's rocket mass heater.
 
subject: Show a PopupMenu using a hotkey