Article View: borland.public.jbuilder.java.swing
Article #9127Popup menu
From: Andreas Andersson
Date: Mon, 15 May 2000 00:00
Date: Mon, 15 May 2000 00:00
51 lines
2053 bytes
2053 bytes
Hi,
I'm having a problem when I try to show a JPopupMenu. I want to enable
stepping with arrows (up & down), disable popup with the escape-key and so
on.... In my implementation I want to show a popup menu when user has right
clicked or used a shortkey (for examlpe Ctrl + m) in a JTable. I have tried
to set focus with the requestfocus method but still I can't get the popup
menu to listen for keys. Is there a way to set the popup menu as modal,
would that help me ?
I would be very happy if anyone out there could help me with this.
Here is how I implemented my JPopupMenu:
// Popup menu
protected JPopupMenu m_tablePopup;
protected Action m_action;
........
void jbInit() throws Exception {
...
m_tablePopup = new JPopupMenu();
PopupAction action1 = new PopupAction(strpopup1);
PopupAction action2 = new PopupAction(strPopup2);
m_tablePopup.add(action1);
m_tablePopup.add(action2);
// Add this popup menu to a table
myTable.add(m_tablePopup);
}
// Class that takes care of Actions on PopupMenu, works fine !!
class PopupAction extends AbstractAction {
public PopupAction(String newNamedAction)
{
super(newNamedAction);
}
...... // All this works fine
}
// In another inner class..
if (me.isPopupTrigger()) // is right mousebutton ??
{
int x = me.getX();
int y = me.getY();
// Here is my problem, this PopupMenu doesn't listen to keystrokes
m_tablePopup.show(ownPatientsViewTable,x,y);
}
Can anyone help me ?
Regards
Andreas
Technical Details
Message-ID:
<3920100f@dnews>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,c6315f5d49219b93,start X-Google-Attributes: gid111d45,public From: "Andreas Andersson" <andreas.andersson@medicinsklogik.se> Subject: Popup menu Date: 2000/05/15 Message-ID: <3920100f@dnews> X-Deja-AN: 623645167 X-Trace: 15 May 2000 07:56:15 -0800, 127.0.0.1 Organization: MLAB X-MSMail-Priority: Normal X-Priority: 3 Newsgroups: borland.public.jbuilder.java.swing X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300