file.setMnemonic(KeyEvent.VK_F);

Discussion in 'OT Technology' started by D1G1T4L, Jun 23, 2003.

  1. D1G1T4L

    D1G1T4L Active Member

    Joined:
    May 4, 2001
    Messages:
    16,489
    Likes Received:
    0
    Location:
    Bay Area
    i use setMnemonic to set a shortcut for File, about and all those submenues, but it seems that it doesn't underline them, even though it suppose underline them, yet if i press the shorcut keys on the keyboard they work


    here is the code

    Code:
    //menu bar
    		JMenuBar mb = new JMenuBar();
    		setJMenuBar(mb);
    		JMenu file = new JMenu("File");
    		JMenuItem exit = new JMenuItem("Exit", KeyEvent.VK_X);
    		JMenu help = new JMenu("Help");
    		JMenuItem about = new JMenuItem("About");
    		file.setMnemonic(KeyEvent.VK_F);
    		//exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK));
    		exit.addActionListener(new MenuBarListener());
    		file.add(exit);
    		help.setMnemonic(KeyEvent.VK_H);
    		about.setMnemonic(KeyEvent.VK_A);
    		about.addActionListener(new MenuBarListener());
    		help.add(about);
    		mb.add(file);
    		mb.add(help);
    
    
    
    here is the pic, notice that F and H are suppose to be underlined
    http://digital.getmyip.com/dpb/MainGUI.jpg
     
  2. D1G1T4L

    D1G1T4L Active Member

    Joined:
    May 4, 2001
    Messages:
    16,489
    Likes Received:
    0
    Location:
    Bay Area
    anybody?
     
  3. D1G1T4L

    D1G1T4L Active Member

    Joined:
    May 4, 2001
    Messages:
    16,489
    Likes Received:
    0
    Location:
    Bay Area
    i read about it and it seems like it's a bug or something and you have to use
    Code:
    file.setMnemonic('f');
    
    going to try it later
     

Share This Page