JDK-6354862 : Scrollpane prevents all it's components from inheriting the FG/BG colors from it's ancestors, XAWT
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: solaris_10
  • CPU: sparc
  • Submitted: 2005-11-23
  • Updated: 2011-04-29
Related Reports
Relates :  
Description
I have added a button to a scrollpane and I have added the scrollpane to a frame. After the frame is made visible, I am changing the Foreground/Background color of the frame on clicking a button. I expect the button to inherit the new color from the frame and change it's label color accordingly. 

But on XToolkit, the button is not inheriting the color from it's parent when the color is changed at run time. Button inherits properly when the color is set for the scrollpane upfront. But when changing the color of either the SP or the frame at runtime, the component is insensitive to it. 

This happens only when I have a scrollpane in the component hierarchy. Whatever is inside the scrollpane becomes insensitive to color changes of it's ancestors. If I replace scrollpane with a panel and change the color of the frame, it works properly.

Everything works fine on Motif and the above issues are seen only on XAWT. Reproducible on Mustang as well as Tiger. On Win32, colors are not at all inherited by the components, be it Scrollpane or Panel. 

I have attached a sample test. Execute the sample test. You would see 2 buttons. One is actually placed inside a panel and other is (right side one) placed inside a scrollpane. Click any of the buttons. This would change the FG color of the frame. Now you would see left side button's label changing to RED color but not the right side button. That's because right side button is placed inside the scrollpane.

Comments
EVALUATION one of the approaches is in overriding setForeground() in XScrollPanePeer and obtaining all peers in it by doing clip.getChildren();
25-11-2005

EVALUATION First this related to FG and BG both (there is a test which deals with FG only but CR is about them both) I checked colors of targets and they are correct - problem reside on peer level. This is a problem caused by design of ScrollPane on XAWT: it uses hidden from the user content window ( XScrollPanePeer: static XScrollPaneContentWindow clip ) which inherited from XWindow. I listed all windows cretaed by the test in XWindow.create() (I was interested in its parameters specifically "visual" of XCreateWindow which should contain colors) but this param. seems to be okay. Then I tried to - move XScrollPaneContentWindow outside of XScrollPanePeer (this allow me to override getGraphics(), getFg/getBg in it) but this had no effect.
25-11-2005