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

JMenuItem font is not inherited by its accelerator text

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.2.2
    • client-libs



      Name: skT88420 Date: 07/09/99


      Regardless of the font setting on a JMenuItem, if an accelerator
      shortcut is available for it, the shortcut is rendered in some font
      which is apparently constant and unchangeable.

      This bug has been untested on OSes other than Win98. It also has not
      been tested under JDK 1.2.2. It has, however, been tested using both
      Metal and Windows look-and-feels, by commenting out a portion of the
      code shown below.


      import javax.swing.*;
      import java.awt.*;

      public class Test
      {
        public static void main (String[] args)
        {
      // comment this out on a Windows box to try Metal L&F
          try {
            UIManager.setLookAndFeel
              (UIManager.getSystemLookAndFeelClassName());
          } catch (Exception ex) { ex.printStackTrace(); }
      // comment this out on a Windows box to try Metal L&F

          JFrame frame = new JFrame();
          Container content = frame.getContentPane();
          content.add(new JButton("for kicks"));

          JMenuItem menuitem = new JMenuItem ("Item");
          menuitem.setAccelerator (
            KeyStroke.getKeyStroke ('I', Event.ALT_MASK));
          menuitem.setFont (new Font ("SansSerif", Font.PLAIN, 24));

          JMenu menu = new JMenu ("Menu");
          menu.add (menuitem);

          JMenuBar menubar = new JMenuBar();
          menubar.add (menu);

          frame.setJMenuBar (menubar);

          frame.pack();
          frame.show();
        }
      }
      (Review ID: 85416)
      ======================================================================

            gsaab Georges Saab
            skonchad Sandeep Konchady
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: