On demand population of dropdown menu Java/Swing?

Posted by Cookie Monster on Stack Overflow See other posts from Stack Overflow or by Cookie Monster
Published on 2012-11-23T10:57:40Z Indexed on 2012/11/23 10:59 UTC
Read the original article Hit count: 159

Filed under:
|
|

When I code a popup menu, I can check the mouse event and then before calling show() prepare the menu.

Now I want a similar functionality for drop down menus, that live in the menu bar. For example I have the following menu bar layout:

Menu 1
   MenuItem 1.1
      MenuItem 1.1.1
      MenuItem 1.1.2
      ..
      MenuItem 1.1.n
Menu 2

Basically I want to generate the list MenuItem 1.1.1, MenuItem 1.1.2, ..., MenuItem 1.1.n dynamically when the drop down menu is invoked and before it is shown.

How could I do this in Java/Swing?

Best Regards

© Stack Overflow or respective owner

Related posts about java

Related posts about swing