I am trying to use the Swing component as part of a menu.
Everything works fine except for one detail: The component contains JComboBox es, and whenever a user clicks on one of them to open a drop-down list, a drop-down menu opens, but the menu disappears. Can I open the menu when I click JComboBox ?
I am subclassed by JMenu . This is the corresponding code:
public class FilterMenu extends JMenu { public FilterMenu(String name) { super(name); final JPopupMenu pm = this.getPopupMenu(); final FilterPanel filterPanel = new FilterPanel(pm) { @Override public void updateTree() { super.updateTree(); pm.pack(); } }; pm.add(filterPanel); } }
FilterPanel is a custom composite component. pm.pack() is called to adapt the size of JPopupMenu when the FilterPanel changes in size.
thanks for the help
source share