I want to set an accelerator to a JMenuItem.
Right now I am setting it like this
openFile.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
and it's working but I don't want ctrl+o as accelerator. I want 'space' as accelerator but I didn't find any method by which I can generate a KeyStroke corresponding to 'space'.
KeyStroke.getStroke()
either takes a char or (int, int). I didn't find any char corresponding to space also.
char
corresponding to space.KeyEvent.VK_SPACE
is an int and there is no method like KeyStroke.getStroke(int) which takes only int. I have to supply some modifier also which I don't want. – Mossy