java - Prevent hiding of contextmenu after selecting CheckMenuItem -
i have contextmenu on textfield (opens on focus) 2 checkmenuitems. selecting 1 menuitem leads hide contextmenu. how can prevent contextmenu hiding after selecting item (to allow more selections)
exampleapp:
public class contextmenutest extends application { @override public void start(stage primarystage) { contextmenu contextmenu = new contextmenu(); checkmenuitem item1 = new checkmenuitem("test1"); checkmenuitem item2 = new checkmenuitem("test2"); contextmenu.getitems().addall(item1, item2); textfield textfield = new textfield(); textfield textfield1 = new textfield(); textfield.focusedproperty().addlistener((object, oldval, newval) -> { if(newval) contextmenu.show(textfield, side.top, 0, 0); }); vbox root = new vbox(); root.getchildren().addall(textfield, textfield1); scene scene = new scene(root, 300, 250); primarystage.setscene(scene); primarystage.show(); } public static void main(string[] args) { launch(args); } }
thanks ideas.
edit: tried setautohide(false) not help
Comments
Post a Comment