The problem can be stated in two different ways:
1. I have a JPopupMenu
where I want to insert a component which is not a JMenuItem
(a custom JTree
)... but I dont know how to do it
or
2. I have a different Popup (JPopupPanel
) and I want 开发者_C百科to add JMenuItems
below my custom JTree
and that those JMenuItems
work as if they were inserted in a JPopupMenu
: they are highlighted when mouse is over and popup is closed when one of them is selected.
Any hints?
NOTE: in 2. I can add the JMenuItems without problem, show they are shown in the Popup, but they dont act as when they are in a JMenu or JPopupMenu
For 1. JPopupMenu
supports insertion of any Component
with the method
public void insert(Component component, int index)
For 2. Did you add an ActionListener to the menu?
精彩评论