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

MenuItems do not inherit parent Menu's font settings on win32

XMLWordPrintable

    • generic, x86
    • solaris_2.5.1, windows_nt

      This bug was discovered after running the example code on page
      1064 of the Java Class Libraries Volume 2 book for JDK 1.1.

      The example is supposed to demonstrate the use of the MenuBar()
      constructor. Creates a menu with a few menu items and sets the font on
      the menu to a large font. On win32, the menu items do not inherit the
      font setting of the Menu. On both Solaris and Win32, calling getfont()
      on the menu items and Menu reports that they are both using the
      same font (the larger size font that was explicitly set).

      Note that the documentation states (for the example) that the fonts should
      not be inherited. It is my understanding that they should be inherited.
      Whatever the case, since win32 and Solaris behave differently, we should
      probably fix one or the other implementation (depending on what the
      correct behavior really is).

      Here is a slightly instrumented version of the sample code...

       import java.awt.*;
        
       class Main {
           static public void main(String[] args) {
               Frame f = new Frame("MenuBar Example");
               MenuBar menubar = new MenuBar();
        
               f.setMenuBar(menubar);
               System.out.println("Menubar Font is "+menubar.getFont());
               Menu menu = new Menu("File");
               menu.setFont(new Font("Monospaced", Font.PLAIN, 32));
               System.out.println("Menu font is "+menu.getFont());
               MenuItem mi = new MenuItem("Edit");
               menu.add(mi);
               System.out.println("The item font is "+mi.getFont());
               menu.add("Save");
               menubar.add(menu);
               f.setSize(100, 100);
               f.show();
           }
        
       }

            ssisunw Ssi Ssi (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: