Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4140869

Spurious underscore under accelerator character

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.0.2, 1.1.6, 1.2.0
    • client-libs
    • generic, x86
    • windows_95, windows_nt



      Name: el35337 Date: 05/21/98


      It appears that the C of "Ctrl+C" is being underlined when Control-C is set as the accelerator key for a menu item whose
      mnemonic is also 'C'. So, for example in an edit menu, with Cut (Ctrl+X), Copy (Ctrl+C), and Paste (Ctrl+V), the C in Ctrl
      will be underlined for the Copy menu item, but not the other two instances of "Ctrl." Here's some sample code to illustrate
      the problem (compiled using Swing 1.0.1):

      import com.sun.java.swing.*;
      import java.awt.event.*;

      class MenuBug
      {
          public static void main(String args[]) {

              JFrame frame = new JFrame("Menu Bug");
              JMenuBar mb = new JMenuBar();
              JMenu menu = new JMenu("BuggyMenu");
              menu.setMnemonic('B');
              JMenuItem mi;
                      mi = new JMenuItem("Cut");
              mi.setMnemonic('U');
              mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,
                  ActionEvent.CTRL_MASK));
                      menu.add(mi);
                      mi = new JMenuItem("Copy");
              mi.setMnemonic('C');
              mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,
                  ActionEvent.CTRL_MASK));
                      menu.add(mi);
              mi = new JMenuItem("Paste");
              mi.setMnemonic('P');
              mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,
                  ActionEvent.CTRL_MASK));
                      menu.add(mi);
              mb.add(menu);
              frame.setJMenuBar(mb);
              frame.show();
          }
      }

      Bob Kline
      ###@###.###
      (Review ID: 27860)
      ======================================================================

            gsaab Georges Saab
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: