My problem is about accelerators on JMenuItem, the accelerator doesn't work if the JMenu is not opened, but only for some of them. For one it is working (CTRL + G), but for another one it is not working (CTRL + H). I have no idea why it doesn't work. (it's working if the JMenu is open I remind it)
Maybe it's about another shortcut already set up on that combination ?
remplacer.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_H, java.awt.event.InputEvent.CTRL_DOWN_MASK));
remplacer.setText("Remplacer");
remplacer.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
remplacerActionPerformed(evt);
}
});
edition_menu.add(remplacer);
atteindre.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_G, java.awt.event.InputEvent.CTRL_DOWN_MASK));
atteindre.setText("Atteindre");
atteindre.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
atteindreActionPerformed(evt);
}
});
edition_menu.add(atteindre);
Here are two JMenuItem contained in a JMenu, one is working anyway, but the other is working only if I open the JMenu before. Thank's for your help.
Seems to work fine for me, consider providing a minimal reproducible example which demonstrates your issue