JMenu Mnemonic characters are displayed permanently

227 Views Asked by At

I have a little Problem, even though my ALT Key isn't down (the key is not broken, neither is it stuck) it permanently highlights the JMenu components (Not just the single menus but also their sub-menu characters) Mnemonic Characters.

Update:

I found out why it happens, it seems to be the L&f. I am currently using Nimbus but if i use the Windows look and feel everything works perfect. So here comes the second question can i somehow change that, i haven't found anything in the nimbus defaults?

MCVE:

import java.awt.event.KeyEvent;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;

public class Main
{
  public static void main( String[] args )
  {
    try
    {
      for ( final LookAndFeelInfo info : UIManager.getInstalledLookAndFeels() )
      {
        if ( "Nimbus".equals( info.getName() ) )
        {
          UIManager.setLookAndFeel( info.getClassName() );
          break;
        }
      }
    }
    catch ( final Exception exception )
    {
      //UNIMPORTANT
    }
    final JFrame frame = new JFrame();
    frame.setSize( 800, 600 );

    final JMenuBar menuBar = new JMenuBar();

    final JMenu testMenu = new JMenu( "testMenu" );
    testMenu.setMnemonic( KeyEvent.VK_T );

    menuBar.add( testMenu );

    frame.setJMenuBar( menuBar );

    frame.setVisible( true );
  }   
}
0

There are 0 best solutions below