Results 1 to 5 of 5
- 12-11-2010, 04:37 PM #1
Member
- Join Date
- Sep 2008
- Posts
- 40
- Rep Power
- 0
Returning the selected menu item from a popup screen
Hi. I'm having trouble returning what item has been seect from a popup window.
When I right click I get my menu-popup, but when I click on a menu item I get nothing.
I've added an action listener to the popup menu. My menu is a sub-menu and I'm trying to get information back from my sub menu.
Any tips please?
Thanks
- 12-11-2010, 04:45 PM #2
Member
- Join Date
- Sep 2008
- Posts
- 40
- Rep Power
- 0
Opps sorted it :-D
-
Please mark the thread "solved" (see thread tools above), and please provide a brief synopsis of your solution. Thanks.
- 12-11-2010, 04:59 PM #4
Member
- Join Date
- Sep 2008
- Posts
- 40
- Rep Power
- 0
private JMenu _createSubMenu(){
_subMenu = new JMenu("Replace");
for(int n = 1; n!= 5; n++){
_subMenu.add("Pad "+ String.valueOf(n));
_subMenu.getItem(n-1).addActionListener(this);
}
return _subMenu;
}
I didn't add an action listener to EACH of the menu items :-D.Last edited by phil128; 12-11-2010 at 05:01 PM. Reason: Solution to my problem
-
Thanks for posting this information. Let me repost your code with code tags:
Java Code:private JMenu _createSubMenu(){ subMenu = new JMenu("Replace"); for(int n = 1; n!= 5; n++){ subMenu.add("Pad "+ String.valueOf(n)); subMenu.getItem(n-1).addActionListener(this); } return _subMenu; }
Similar Threads
-
popup menu
By jperson in forum New To JavaReplies: 3Last Post: 09-18-2010, 01:44 PM -
how to add beforeClick action for a popup menu item added by another plug-in
By serkan kirbas in forum EclipseReplies: 0Last Post: 07-13-2010, 09:16 AM -
How to get the selected item from combox
By man4ish in forum AWT / SwingReplies: 5Last Post: 12-30-2009, 10:29 AM -
SELECTED select menu??
By Samurai Coder in forum New To JavaReplies: 1Last Post: 12-03-2009, 06:09 PM -
how to create Popup Menu with Sub Menu while right-clicking the JTree Node??
By Kabiraa in forum AWT / SwingReplies: 7Last Post: 05-09-2008, 07:54 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks