java - JMenu's pop-up will not close when the cursor leaves the JMenu -
jbutton jbutton1 = new jbutton("click me"); public void showpopupmenu1(jbutton invoker){ jpopupmenu popupmenu = new jpopupmenu(); popupmenu.setlayout(new gridlayout(5, 1)); jmenu menu = new jmenu("other"); menu.add(new jmenuitem("a")); menu.add(new jmenuitem("b")); menu.add(new jmenuitem("c")); popupmenu.add(menu); popupmenu.add(new jbutton("apple")); popupmenu.add(new jbutton("banana")); popupmenu.add(new jbutton("carrot")); popupmenu.add(new jbutton("orange")); popupmenu.show(invoker, 0, invoker.getheight()); } private void jbutton1actionperformed(java.awt.event.actionevent evt) { showpopupmenu1(jbutton1); }
when cursor goes apple button, menu's popup not close , still marked selected.
Comments
Post a Comment