JavaFX editable combo box -
i trying use editable combo box. in want add listener pressing enter key. tried below options none of them working.:(
cmb_year
combo box object.
cmb_year.setonkeypressed(new eventhandler<keyevent>() { @override public void handle(keyevent t) { if (t.getcode() == keycode.enter) { system.out.println("entered"); } else if (t.getcode() == keycode.escape) { system.out.println("entered"); }else { } } }); cmb_year.geteditor().setonkeypressed(new eventhandler<keyevent>() { @override public void handle(keyevent t) { if (t.getcode() == keycode.enter) { system.out.println("entered"); } else if (t.getcode() == keycode.escape) { system.out.println("entered"); }else { } } });
you can use code:
cmb_year.addeventfilter(keyevent.key_pressed,new eventhandler<keyevent>() { @override public void handle(keyevent t) { if (t.getcode() == keycode.enter) { system.out.println("entered"); } else if (t.getcode() == keycode.escape) { system.out.println("entered"); }else { } } });
Comments
Post a Comment