Good question. I just tried this on OS X, and I do not get the underlined letters either. Just like you I get them by hitting the alt button (not during click, but when my pop-up menu is shown).
However, on OS X I cannot remember any pop-up which contains underlined letters. I just checked some of the default applications and none of them have a pop-up menu with underlined items. A quick Google search indicated this as well. So in this case, the look-and-feel is consistent with the OS.
After some more googling, I found the following topic which suggest that in Windows there is an option to hide the mnemonics by default, and only show them when you press alt (which you need to press anyway to use the mnemonic if I remember correctly from my windows days). You might want to try that.
Anyhow, here is an SSCCE allowing windows users to quickly test this:
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPopupMenu;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
public class MnemonicTest {
public static JFrame createUI(){
JFrame testFrame = new JFrame( );
testFrame.add( createLabelWithPopupMenu() );
testFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
testFrame.pack();
return testFrame;
}
private static JLabel createLabelWithPopupMenu(){
JLabel result = new JLabel( "Right-click me" );
result.setComponentPopupMenu( createPopupMenu() );
return result;
}
private static JPopupMenu createPopupMenu(){
JPopupMenu popupMenu = new JPopupMenu( );
popupMenu.add( createAction() );
return popupMenu;
}
private static Action createAction(){
AbstractAction result = new AbstractAction() {
@Override
public void actionPerformed( ActionEvent e ) {
System.out.println( "MnemonicTest.actionPerformed" );
}
};
result.putValue( Action.MNEMONIC_KEY, KeyEvent.VK_A );
result.putValue( Action.NAME, "Action" );
return result;
}
public static void main( String[] args ) {
EventQueue.invokeLater( new Runnable() {
@Override
public void run() {
createUI().setVisible( true );
}
} );
}
}