i've problem setaccelerator(). right now, have code works ctrl+x delete operation. want set accelerator shift+delete same jmenuitem.
my code follows:
jmenuitem item = new jmenuitem(menutext); item.setaccelerator(keystroke.getkeystroke( keyevent.vk_x, keyevent.ctrl_mask)); item.setaccelerator(keystroke.getkeystroke( keyevent.vk_delete, keyevent.shift_mask)); but working shift+delete operation. seems overriding ctrl+x operation. can make both these keystrokes work @ same time?
please guide.
yes can done. behind scenes setaccelerator() creating key binding, noticed second binding replaces first.
so, need create action (not actionlistener) add menu item. read section swing tutorial on how use actions more information. have created action, can share action keystroke manually creating key binding. can read section swing tutorial on how use key bindings detailed explanation. or can read blog on key bindings give simple code examples.
this second binding not show on menu item itself.
Comments
Post a Comment