Hi guys,
Trying to get a tab character into a JMenuItem
using \t
but it's not printing.
I bet it's something really basic I'm missing. Here's the code
menuItem = new JMenuItem("New\tCtrl + N");
Thanks
Hi guys,
Trying to get a tab character into a JMenuItem
using \t
but it's not printing.
I bet it's something really basic I'm missing. Here's the code
menuItem = new JMenuItem("New\tCtrl + N");
Thanks
Try this instead:
menuItem = new JMenuItem("New");
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
You should also add mnemonics for usability:
menuItem.setMnemonic(KeyEvent.VK_N);
See the Java Look and Feel Guidelines for greater clarification, especially volume 1.