Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JMenu as a submenu  RSS feed

 
Raymond du Toit
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really need help!
I have a JMenubar containing a few JMenu's. One of the menu's have submenu's (JMenu) and then one of these menu's contain some submenu's (JMenu).
Here is the method I use to populate the menu with either JMenuItem's or JMenu's. The problem is that some of the submenu's or JMenu's in the main JMenu does not open when the mouse pointer is moved over it. Does anyone have suggestions, please?
------------------------------
public void populateMenu(JMenu menu, ArrayList al){

HTMLLink linkObject;

for(int i=0; i< al.size(); i++){
linkObject = (HTMLLink) al.get(i);
if(linkObject.getLink() instanceof ArrayList){
JMenu itemMenu = new JMenu(linkObject.getName());
populateMenu(itemMenu, (ArrayList)linkObject.getLink());
menu.add(itemMenu);
}
else{
menu.add(new JMenuItem(linkObject.getName()));
}
}
}
 
Raymond du Toit
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fixed the problem by adding the following code:

itemMenu.getPopupMenu().setLightWeightPopupEnabled(false);
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!