0

Hi,

I am trying to create an editor using JTextpane. Now I need to show a dynamic pop up menu while pressing Ctrl + space. But the problem is that I can trigger the pop up menu only by right click of mouse. The code snippet that I used is given below.

           frame.addMouseListener(new MouseAdapter(){
                public void mouseReleased(MouseEvent Me){
                  if(Me.isPopupTrigger()){
                    Pmenu.show(Me.getComponent(), Me.getX(), Me.getY());
                  }
                }
              });

I am able to invoke Ctrl + space.. But not able to invoke pop up menu using this.Is there any method or short cut to trigger pop up menu using key board? Please help...

Thanks in advance......

Edited by Nick Evan: Fixed formatting

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by mKorbel
0

Have a look at the KeyListener interface in the API doc - it allows you to respond to individual keys being pressed and/or released.

0

just about JPopupMenu

I'm not sure if is posible invoke JPopupMenu (rightMouseClick) with KeyBindings,

if is posible (excluding JTable) i'd prefered JDialog with JButtons,

well I tried lots of hack for JPopumMenu, but each has problem with Concurency on EDT

if you want to add JPopupMenu correctly, then add its listener to JTextPane instead of JFrame,

and create own PopupListener extends MouseAdapter, because you can pretty modify JPopupItem (dynamic contents) in

public void mouseReleased(MouseEvent e) {
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.