by Dinesh Thakur

 

import java.awt.*;

import javax.swing.*;
import java.awt.event.*;
public class JavaExampleMenuAcceleratorInJApplet extends JApplet implements ActionListener
 {
    public void init()
      {
        Container Cntnr = getContentPane();
        JMenuBar MnuBar = new JMenuBar();
        JMenu Mnu = new JMenu("File");
        JMenuItem MnuItm = new JMenuItem("New...");
        Mnu.add(MnuItm);
        Mnu.add("Open ...");
        Mnu.addSeparator();
        Mnu.add("Exit");
        MnuItm.setMnemonic(KeyEvent.VK_N);
        KeyStroke KeyStrk = KeyStroke.getKeyStroke(KeyEvent.VK_N, Event.CTRL_MASK);
        MnuItm.setAccelerator(KeyStrk);
        MnuItm.addActionListener(this);
        MnuBar.add(Mnu);
        setJMenuBar(MnuBar);
      }
        public void actionPerformed(ActionEvent e1)
         {
           showStatus("You Choose New Item");
         }
 }
/*<APPLET CODE=JavaExampleMenuAcceleratorInJApplet.class WIDTH = 350 HEIGHT = 280 ></APPLET>*/
MenuAccelerator in Java example