Setting a Keyboard Accelerator for a Menu Item
import java.awt.event.KeyEvent;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;
public class Main {
public static void main(String[] argv) throws Exception {
JMenuItem item = new JMenuItem("Item");
item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, KeyEvent.SHIFT_MASK));
}
}
Related examples in the same category