java - JButton keyboard shortcuts -
i have 2 jbutton
s , allow them used keyboard arrow keys whenever jframe
has focus.
can point me in right direction this?
modified swing's action demo.
the initialization of button:
// sets mnemonic down, no hint display jbutton down = new jbutton(new downaction("down", null, "this down button", new integer(keyevent.vk_down));
the action:
class downaction extends abstractaction { public downaction(string text, imageicon icon, string desc, integer mnemonic) { super(text, icon); putvalue(short_description, desc); putvalue(mnemonic_key, mnemonic); } public void actionperformed(actionevent e) { displayresult("action first button/menu item", e); } }
Comments
Post a Comment