javafx - Close Event Cusom Menu Item -
javafx - Close Event Cusom Menu Item -
first want apologize bad english. problem is, have implemented in javafx new class extends custommenuitem.´
i want menu can handle custommenuitem, when there click on it, hide event should not there. want have menu in front...
at moment onactionevent (click) starts event want, finish menu hides. i'm not confirmed javafx, don't know how can grab close/hide event finish menu.
is there solution it?
thanks help.
your question hard understand, think looking calling
sethideonclick(false);
in custommenuitem
subclass' constructor, in next example:
import javafx.application.application; import javafx.scene.scene; import javafx.scene.control.custommenuitem; import javafx.scene.control.label; import javafx.scene.control.menu; import javafx.scene.control.menubar; import javafx.scene.layout.borderpane; import javafx.stage.stage; public class nonhidingmenu extends application { @override public void start(stage primarystage) { menu menu = new menu("file"); menu.getitems().addall(new nonhidingmenuitem("new")); menu.getitems().addall(new nonhidingmenuitem("open")); menubar menubar = new menubar(); menubar.getmenus().add(menu); borderpane root = new borderpane(null, menubar, null, null, null); primarystage.setscene(new scene(root, 400, 400)); primarystage.show(); } public static class nonhidingmenuitem extends custommenuitem { public nonhidingmenuitem(string text) { setcontent(new label(text)); sethideonclick(false); setonaction(event -> system.out.println("selected "+text)); } } public static void main(string[] args) { launch(args); } }
javafx custom-controls menuitem
Comments
Post a Comment