Request for review: 7124530 What is background color of AWT component? (And foreground, for that matter)

Anthony Petrov anthony.petrov at oracle.com
Tue Jan 10 08:51:23 PST 2012


Hi Sergey,

src/macosx/classes/sun/lwawt/LWWindowPeer.java
>  140         if (!target.isBackgroundSet()) {
>  141             target.setBackground(SystemColor.window);
>  142         } else {
>  143             // first we check if user provided alpha for background. This is
>  144             // similar to what Apple's Java do.
>  145             // Since JDK7 we should rely on setOpacity() only.
>  146             // this.opacity = c.getAlpha();
>  147             // System.out.println("Delegate assigns alpha (we ignore setOpacity()):"
>  148             // +this.opacity);
>  149         }

A couple of questions regarding this piece of code:

1. Why do we need the else{} branch here? Are we going to use it? How? 
Should the comment explain this future use?

2. What do you mean by saying "we should rely on setOpacity() only"? The 
alpha value of the background color and the alpha value returned by 
getOpacity() are different kinds of opacity: the former affects the 
background surface of the window only, whilst the latter affects the 
entire window's surface including any content explicitly painted on top 
of the background.

--
best regards,
Anthony

On 1/10/2012 7:33 PM, Sergey Bylokhov wrote:
> Hi Everyone,
> 
> Does anybody have a comments?
> 
> 29.12.2011 17:34, Sergey Bylokhov wrote:
>> Hi Everyone,
>> This is a fix for some glitches in the code for 
>> background/foreground/font properties.
>> 1. SystemColor.window was changed to color which is used by default in 
>> swing l&f(Aqua). Changes in AquaImageFactory.java and CSystemColors.m. 
>> Now most of the awt components use this color as default.
>> 2. set** methods were moved from LWWindowPeer to LWComponentPeer, 
>> because there is an issues when these methods has no effect, because 
>> repaint of the component does not happen.For example:
>>  - call Label.setbackground which set component background property
>>  - call Peer.setBackground
>>  - call Delegate.setBackgound
>>  - compare passed color with color from Label property, which was set 
>> in the first step: changes in 
>> LWWindowPeer,LWContainerPeer,LWComponentPeer.
>> 3. List default color was changed to SystemColor.text: changes in 
>> LWListPeer.java.
>> 4. LWWIndow target color initialization was moved from CPlatformIndow 
>> to LWWindowPeer, so it can be reused later by CPlatformEmbeddedFrame .
>> 5. unnecessary peers set** methods and unnecessary delegate in 
>> LWCanvasPeer were removed: changes in LWCanvasPeer.java, 
>> LWListPeer.java, LWPanelPeer.java.
>>
>> Bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7124530
>> Webrev can be found at: 
>> http://cr.openjdk.java.net/~serb/7124530/webrev.00/
>>
> 
> 


More information about the macosx-port-dev mailing list