You are here:   HomeJava ProgrammingSwingshowInputDialog Java Swing Example
by Dinesh Thakur Category: Swing

 

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




Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to contact us.



What's New and Popular





Popular Article