<Swing Dev> [8] Review request for 7156657 Version 7 doesn't support translucent popup menus against a translucent window

Artem Ananiev artem.ananiev at oracle.com
Wed Jun 6 15:38:29 UTC 2012

We discussed this fix with Pavel offline, and I agree with the proposed 
changes. When setLightWeightPopupEnabled() was introduced, it gave 
developers flexibility to decide whether they want lightweight popups if 
they fit into Window bounds. The fix for 7027486 removed this 
flexibility in certain cases (shaped and translucent windows), which I 
personally consider bad. Now we're restoring the old behavior.

Note that after the fix, developers will have full control over popup 
lightweightness. If they want the current behavior, they will call 
setLWPE(false) - exactly the change in TransparentRuler. But they also 
be able to be lightweight if they know that popups will fit into their 
nice shaped and/or translucent window - the ability they don't have 
right now.



On 6/6/2012 5:23 PM, Anthony Petrov wrote:
> Hi Pavel and Swing team,
> On 6/6/2012 6:57 PM, Pavel Porvatov wrote:
>> Hi Anthony,
>>> On 6/6/2012 5:05 PM, Pavel Porvatov wrote:
>>>>> I don't understand why this change is necessary. The current code
>>>>> simply detects if a window is non-opaque and forces HW popups for
>>>>> such windows. This works automatically and is very useful.
>>>> Yes, it's very useful but produces the regression that described in
>>>> CR 7156657.
>>>>> With this fix, however, most developers who use translucent
>>>>> windows, will have to manually call
>>>>> setLightWeightPopupEnabled(false), which doesn't look
>>>>> developer-friendly. Also, it changes the current behavior causing a
>>>>> regression.
>>>> Current behavior contains a regression from older release jdk6, so
>>>> reverting fix of CR 7027486 (JPopupMenu doesn't take window shape
>>>> into account) doesn't look like a regression.
>>> Given that the current behavior exists since 7 GA, this will be a
>>> regression, too. So, all in all, we're discussing two regressions here.
>> Ok
>>>>> Instead of changing our own demo code and affecting developers who
>>>>> might have already relied on the current behavior, why not simply
>>>>> suggest the submitters of 7156657 to force LW popups for their
>>>>> specific use case?
>>>> Unfortunately there is no way to force LW popups, so there is no
>>>> workaround for the problem
>>> I see. Did you consider introducing such possibility?
>>> E.g. we could leave the behavior introduced with 7027486 as is, and
>>> only turn it off when a system property is specified. This would
>>> resolve the issue reported by the submitter, and at the same time
>>> would preserve the useful behavior we have since the 1.7.0 release.
>> Actually I don't like idea to introduce new system properties or new
>> API in this case because of the following reasons:
>> 1. More compact API looks better. In suggested fix there is only
>> setLightWeightPopupEnabled method and it covers all use cases.
>> 2. Fix of CR 7027486 (JPopupMenu doesn't take window shape into
>> account) breaks very old behavior of the
>> javax.swing.JPopupMenu#setLightWeightPopupEnabled method: after the
>> fix light weight popups become heavy weight (for translucent and
>> shaped windows)
> I disagree here. Translucent/shaped window have become
> *not-quite-officially* supported since JDK6 only via the
> com.sun.awt.AWTUtilities API, which is not officially supported. In JDK
> 7 we introduced public API for translucent windows, and also integrated
> a fix for 7027486 that only affected non-opaque windows (which again,
> are only officially supported since JDK 7). So I don't agree that a fix
> for 7027486 breaks anything. In most cases it helps.
>> 3. If we implement the fix as you suggested then we should add in
>> javadoc something like this: "setLightWeightPopupEnabled doesn't work
>> in some cases (for translucent and shaped window). For fix that you
>> must set 'blablabla' system property"... =)
> This is not quite correct. In fact, I think a fix for 7027486 should
> have updated the specification to state that popups in non-opaque
> windows are forced to be HW. But this hasn't been done.
> Also, if we want to introduce a new system property, and then port the
> fix to 7uX, then it shouldn't be a part of public API, and thus
> shouldn't be mentioned in the specification. This could be some kind of
> "sun.swing.*" or "sun.awt.*" system property.
>> 4. We can add system property that will force heavy weight for the
>> application later. I'd prefer to don't introduce such property unless
>> somebody ask about that.
> It's a very simple use-case to imagine - a round-shaped window with a
> popup menu. Currently it will work just great. But if you remove the fix
> for 7027486, a developer will have to modify their app to call the
> setLightWeightPopupEnabled(true) explicitly, which may seem inconvenient.
> In any case, I don't think we should simply drop the functionality
> introduced with 7027486. It must be available either by default (which
> personally I prefer), or as an option.
> What do others think about this issue?
> --
> best regards,
> Anthony
>> Regards, Pavel
>>> --
>>> best regards,
>>> Anthony
>>>> Regards, Pavel
>>>>> --
>>>>> best regards,
>>>>> Anthony
>>>>> On 6/6/2012 3:08 PM, Pavel Porvatov wrote:
>>>>>> Hello,
>>>>>> Please review a fix for the following issue:
>>>>>> 7156657 Version 7 doesn't support translucent popup menus against
>>>>>> a translucent window
>>>>>> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7156657
>>>>>> The webrev is here: http://cr.openjdk.java.net/~rupashka/7156657/
>>>>>> <http://cr.openjdk.java.net/%7Erupashka/7156657/>
>>>>>> The fix of CR 7027486 (JPopupMenu doesn't take window shape into
>>>>>> account, http://hg.openjdk.java.net/jdk8/awt/jdk/rev/9024198193ce)
>>>>>> doesn't take into account that some users use translucent windows
>>>>>> with translucent menus. After discussions the following decision
>>>>>> was made:
>>>>>> 1. When JPopupMenu#setLightWeightPopupEnabled is set to false
>>>>>> HEAVY_WEIGHT popups is used (instead of MEDIUM_WEIGHT). This fix
>>>>>> was done in CR 6800513 (GTK-LaF renders menus incompletely,
>>>>>> http://hg.openjdk.java.net/jdk8/awt/jdk/rev/cd00d68e06ac and
>>>>>> http://hg.openjdk.java.net/jdk8/awt/jdk/rev/8800a98316b2) and that
>>>>>> allows to use non-translucent and non-clipped popups for
>>>>>> translucent or shaped windows
>>>>>> 2. Fix of CR 7027486 should be reverted
>>>>>> 3. The TransparentRuler should be corrected according new fix
>>>>>> Regards,
>>>>>> Pavel.

More information about the swing-dev mailing list