Setting a Keyboard Accelerator for a Menu Item - Java Swing

Java examples for Swing:Menu

Description

Setting a Keyboard Accelerator for a Menu Item

Demo Code

import java.awt.event.KeyEvent;

import javax.swing.JMenuItem;
import javax.swing.KeyStroke;

public class Main {
  public static void main(String[] argv) {
    JMenuItem item = new JMenuItem("Item");
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I,
        KeyEvent.SHIFT_MASK));//ww w . j ava2  s . c  o m
  }
}

Related Tutorials