JDK-6371452 : Spec issues with foreground/background inheritance and defaults
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0,1.4.2,5.0,6,7
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • OS:
    linux,solaris_9,windows_98,windows_xp linux,solaris_9,windows_98,windows_xp
  • CPU: x86,sparc
  • Submitted: 2006-01-11
  • Updated: 2017-05-19
  • Resolved: 2010-08-09
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Description
THE TEXT BELOW WAS FIXED FOR INACCURACIES - PLEASE RE-READ

The spec for Component.getForeground() currently states:

  if this component does not have a foreground color, the foreground color of its 
  parent is returned.

Our customers and our internal J2ME implementation team were interpreting it that 
the foreground color is always inherited from the parent if it's not explicitly 
set. This interpretation doesn't match J2SE behavior for TextComponents, and the
spec for setForeground() seems to hint that inheriting only happens if the child's
foreground is set to null (explicitly or via a default value). The spec for 
getForeground() should say something like this instead:

  if this component HAS ITS foreground color SET TO NULL (EITHER EXPLICITLY OR BY
  DEFAULT), the foreground color of its parent is returned AND USED FOR RENDERING.

Another issue is related to the default: which Components have nulls as defaults,
and therefore implicitly inherit parent's settings. Sun's J2SE seems to have null
defaults for all realized components except for TextComponents.
This issue should be clarified in the spec as well.

Third, it's unclear what inheriting from parent means when the component doesn't
have a parent (such as Window). The spec should specifically cover this case.

Finally, the exact same set of issues applies to background color. There might be 
other Component properties that have the same inheritance issues - if this is the 
case, we might want to cover them as well.

Comments
EVALUATION That have much in common to 5006707 which is closed as 'Will Not Fix'. If there are other reasons we could back to it.
09-08-2010

SUGGESTED FIX http://ccc.sfbay/6371452
11-02-2008

EVALUATION Taking into account that 5006707 is now in WNF state, the spec should cover all mentioned issues.
04-07-2007

EVALUATION 1) agree, that clarification should be done. 2) every component except toplevels (Dialod, Window, Frame) has default null colors. Once we fix 6371588 this problem eliminates. 3) is it reasonable to override isForegroundSet()/isBGSet in Window/Frame/Dialog with appropriate description there? 4) sure.
16-01-2006