JDK-6371588 : TextField and TextArea never inherit foreground and background colors
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0,6
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_9
  • CPU: sparc
  • Submitted: 2006-01-12
  • Updated: 2011-03-29
  • Resolved: 2007-07-04
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description
Contrary to the spec requirements, TextField and TextArea cannot inherit foreground
and background colors from the parent window. Calling setForeground/setBackground(null)
has no effect (tried JDK 1.4 through 1.6, several window managers). Note that
isForegroundSet/isBackgroundSet() returns false, implying that the colors will be
inherited.

Note that setting colors explicitly to a non-null value works fine, so this doesn't
seem to be related to limitations of particular window managers.

A sample class to play with is attached.

Comments
EVALUATION Will be handled within 6371452 patch with spec change only.
04-07-2007

EVALUATION TextFields' fix is much simpler then TextArea as there are additional elements like scrollbars etc appearing. Should analize the fix more deeper as consequences are not very obvious.
29-05-2006

SUGGESTED FIX *** /tmp/geta27027 2006-05-29 19:11:51.000000000 +0400 --- XTextFieldPeer.java 2006-05-29 19:10:53.000000000 +0400 *************** *** 117,126 **** if (!target.isBackgroundSet()) { // This is a way to set the background color of the TextArea // without calling setBackground - go through reflection ! ComponentAccessor.setBackground(target, background); } if (!target.isForegroundSet()) { ! target.setForeground(SystemColor.textText); } setFont(font); --- 117,126 ---- if (!target.isBackgroundSet()) { // This is a way to set the background color of the TextArea // without calling setBackground - go through reflection ! setBackground(target.getBackground()); } if (!target.isForegroundSet()) { ! setForeground(target.getForeground()); } setFont(font);
29-05-2006

EVALUATION There is a huge discussion in 5006707 about color inheritance. That deal with all three supported platforms. A CCC for that was rejected. But here we have a contradiction in implementation with the spec and fixing it should not be a problem.
12-01-2006