JDK-4414599 : awt.MenuBar setFont() works incorrectly
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_2.6
  • CPU: generic
  • Submitted: 2001-02-13
  • Updated: 2014-09-26
  • Resolved: 2011-10-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b01Fixed
Related Reports
Relates :  
Relates :  
Description
java.awt.MenuBar.setFont() doesn't set font correctly for the MenuBar
in:
   jdk 1.3 
   jdk1.4 (solaris only).

java.awt.MenuComponent.setFont() spec says:
------------------------------------------
setFont

public void setFont(Font f)

    Sets the font to be used for this menu component to the specified font. This
                                                                            ^^^^
font is also used by all subcomponents of this menu component, unless those 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
subcomponents specify a different font.
    Parameters:
        f - the font to be set.
    See Also: 
        getFont()

----------------------------------------------

MenuBar.setFont() sets the font ONLY for the components that weren't already 
added to the MenuBar. The Menus that were added to the MenuBar 
before the setFont() call are still displayed using the default font.

An example below demonstartes the problem. The setFont() call changes 
the font menu4, menu5 and menu6. 
menu1, menu2, menu3 are still displayed in the old font.

This needs to be fixed. setFont() should change the font of ALL menus 
in the MenuBar.

import java.awt.*;

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

        Frame f = new Frame();
        MenuBar pm = new MenuBar();
        f.setMenuBar(pm);

        f.setSize(600, 100);
        f.setVisible(true);
        
        pm.add(new Menu("menu1"));
        pm.add(new Menu("menu2"));
        pm.add(new Menu("menu3"));

        pm.setFont(new Font("Dialog", Font.BOLD, 30));

        pm.add(new Menu("menu4"));
        pm.add(new Menu("menu5"));
        pm.add(new Menu("menu6"));  
        
    }
}


Comments
EVALUATION I have comitted this bug to Merlin for tracking purposes. It isn't clear exactly what we are going to do to resolve this issue. However, we have been discussing the issue, and we intend to resolve it in some fashion for Merlin. eric.hawkes@eng 2001-02-13 Since spec changes aren't likely to be accepted for Hopper, committing to Tiger. ###@###.### 2001-12-02
13-02-2001