<Swing Dev> [11] Review Request: 8205144 JSpinner may change the font after became visible

Prasanta Sadhukhan prasanta.sadhukhan at oracle.com
Thu Jun 21 06:01:57 UTC 2018


Looks good to me.

Regards
Prasanta
On 6/21/2018 4:37 AM, Sergey Bylokhov wrote:
> Hello.
> Please review the fix for jdk11.
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8205144
> Webrev: http://cr.openjdk.java.net/~serb/8205144/webrev.00
>
> Our implementation of JSpinner tries to maintain the font which is 
> used in the text field inside spinner. There are three cases when the 
> font of the text field should be changed to the font of spinner(if the 
> font of text field was not set by the user).
>  - By default when the spinner is created(fixed in JDK-6421058)
>  - When the user change the font of the spinner(fixed in JDK-5036022)
>
> And there is one more case which should be taken into account. It is 
> possible that LaF can change the font of text field to the font which 
> is used by default by all textfields in this LaF. It is possible to 
> reproduce this using:
> ==========
>     /**
>      * A simple minded look and feel change: ask each node in the tree
>      * to <code>updateUI()</code> -- that is, to initialize its UI 
> property
>      * with the current look and feel.
>      */
>     public static void updateComponentTreeUI(Component c)
>
> ==========
>
> This method will iterate over hierarchy of the components and call 
> updateUI() for each components, then its children, and so on. This is 
> a situation when the bug is reproduced. During updateUI() in JSpinner 
> the font of internal text field will be set to the font of the 
> spinner, but later when the updateUI() will be called for the text 
> field itself the font will be set to default font of of all text fields.
>
> The problem is not reproduced if the application do not change the LaF 
> on the fly, because in this case we call updateUI() for spinner after 
> updateUI() for internal text field.
>
> The fix will reject all fonts(UIResource) which were not set by the 
> user, except the font of the spinner.
>




More information about the swing-dev mailing list