I am working in an English app on a german laptop, over a spanish OS.
Even if I explictly set Locale.setDefault(Locale.ENGLISH) at the beggining of my app, I am seei
You have to make sure that you set the locale before any toolkit code is executed. The following code shows the effect: if you move the Locale.setDefault(Locale.GERMAN);
to any other line it will show the default accelerator names again.
Instead of setting the locale inside your code you may also append the following argument to the VM:
-Duser.language=DE
public class MenuLocale {
public static void main(String[] args) {
Locale.setDefault(Locale.GERMAN);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
JMenuBar menubar = new JMenuBar();
JMenu menu = new JMenu("Menu");
JMenuItem menuitem = new JMenuItem("Menuitem");
menuitem.setAccelerator(KeyStroke.getKeyStroke('X', KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK));
f.setJMenuBar(menubar);
menubar.add(menu);
menu.add(menuitem);
f.pack();
f.setVisible(true);
}
});
}
}