<Swing Dev> RFR: 8253266 : JList and JTable constructors should clear OPAQUE_SET before calling updateUI

Prasanta Sadhukhan psadhukhan at openjdk.java.net
Wed Mar 24 08:30:41 UTC 2021


On Wed, 24 Mar 2021 06:17:04 GMT, Tejpal Rebari <trebari at openjdk.org> wrote:

> Hi All,
> Please review the following fix for jdk17.
> 
> Issue : LookAndFeel.installProperty(list, "opaque", false) is not able to set the opaque property for JList and JTable.
> LookAndFeel.installProperty calls the setUIProperty, and setUIProperty checks for OPAQUE_SET to change the opaque property as requested by the client.
> OPAQUE_SET is always set to true when there is call to setOpaque(boolean).So when the constructor calls setOpaque(true) OPAQUE_SET is set to true and wont allow the setUIProperty to change the opaque property.
> installProperty should work as the opaque property is not set by the client.
> 
> Fix. Fix is to remove the call to the setOpaque() from the constructor of JList and JTable. This will allow the client to change the opaque property calling LookAndFeel.installProperty() when the property is already not set.
> 
> Test : Added a  test  to check the same. Also tested internal tests which all are passing.
> Link is in JBS.

I am not sure if this is the correct fix, as then we would have to remove setOpaque call for JTree, JToolTip, JRootPane etc where we might face same installProperty issue. 
Also, if we have to change this, we then need to change "autoScrolls" property too which is set in this 2 component and setUIProperty() can change those too.
Probably, we need to check if the value to be set is different in setUIProperty and then set it 
or 
override setUIProperty per component basis (as it is done for JTable) and then not check for OPAQUE_SET flag for opaque property accordingly.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3167


More information about the swing-dev mailing list