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

Tejpal Rebari trebari at openjdk.java.net
Thu Mar 25 06:36:40 UTC 2021


On Wed, 24 Mar 2021 08:27:40 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> 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.

Yes we face the same issue in JTree, JToolTip, and JViewport , 
but many of the components do not  have this problem like JButton JRootPane , JCheckbox, JInternalFrame, JMenuItem, JCheckBoxMenuItem, JPopupMenu, JMenu ..etc
We can fix the issue with JTree, JTooltip and JViewport same way.

> 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.

OPAQUE_SET is private variable and can not be accessed in JTable or JTree. 
>From the spec of LookAndFeel.installProperty and setUIProperty it
  * Sets the property with the specified name to the specified value if
     * the property has not already been set by the client program.*
 is clear that once the property is set by the client setUIProperty can not change it. And OPAUQE_SET  is  used  for  that
.

Removing the setOpaque() from the constructor of these component will not make any initial difference as it is also set to true in BasicListUI, BasicTableUI, BasicTreeUI, BasicTooltipUI and BasicViewportUI by calling LookAndFeel.installProperty.
The difference which it will make is now by calling LookAndFeel.installProperty(c,opaque,false) will clear the opaque property.

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

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


More information about the swing-dev mailing list