Please following example of java, which will help you to know about the JMenuItem class:
Code:
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;
public class JMenuItemDM {
public static void main(final String args[]) {
JFrame VO = new JFrame("MenuSample Example");
VO.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
fileMenu.setMnemonic(KeyEvent.VK_F);
menuBar.add(fileMenu);
JMenuItem PMIT = new JMenuItem("Paste", KeyEvent.VK_P);
KeyStroke ctrlVKeyStroke = KeyStroke.getKeyStroke("control V");
PMIT.setAccelerator(ctrlVKeyStroke);
PMIT.setEnabled(false);
fileMenu.add(PMIT);
VO.setJMenuBar(menuBar);
VO.setSize(250, 250);
VO.setVisible(true);
}
}
Bookmarks