문제

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 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?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top