Type a File menu with a mnemonic, added to a menu bar on the frame
Type a File menu with a mnemonic, added to a menu bar on the frame
Answer
JMenu file = new JMenu("File"); file.setMnemonic(KeyEvent.VK_F); JMenuBar bar = new JMenuBar(); bar.add(file); frame.setJMenuBar(bar);
setMnemonic gives Alt+F to open the menu; setJMenuBar (not add) installs the bar in the frame’s menu slot.