<Swing Dev> Review Request for Bug 8146320 JTextField ignores setPreferredSize when having columns
Prem Balakrishnan
prem.balakrishnan at oracle.com
Fri Feb 26 04:33:22 UTC 2016
Hi Sergey,
Thanks for the Detailed clarification.
And yes you are right, this fix may break the layout of existing applications and make them unusable.
We got vote against the fix by: Andrej Golovnin(refer link below)
http://mail.openjdk.java.net/pipermail/swing-dev/2016-January/005352.html
We should probably go with Documentation update :
/**
* Returns the preferred size <code>Dimensions</code> needed for this
* <code>TextField</code>. If a non-zero number of columns has been
* set, the width is always set to the columns multiplied by
* the column width, even when preferred size is set explicitly.
*
* @return the dimension of this textfield
*/
public Dimension getPreferredSize()
Regards,
Prem
-----Original Message-----
From: Sergey Bylokhov
Sent: Thursday, February 25, 2016 4:13 PM
To: Prem Balakrishnan; Alexander Scherbatiy; Ambarish Rapte; Rajeev Chamyal; swing-dev at openjdk.java.net
Subject: Re: Review Request for Bug 8146320 JTextField ignores setPreferredSize when having columns
Hi, Prem.
It seems that I was not clear in my previous email. Small clarification:
Usually we can fix/change an existed code in a few situations:
1 Behavior is changed if it contradicts the specification.
2 The specification is changed if it contradicts the long-term behavior
3 If some behavior is unspecified and can varies from platform to platform(usually we clarify the spec and align implementation).
In your fix you change the spec and behavior. So initially, some time ago, someone wrote this specification and implemented behavior of JTextField according to this specification. So applications depend from this behaviour(which is properly specified) and we simply cannot change it now.
On 21.01.16 8:52, Prem Balakrishnan wrote:
> Hi, Prem.
> This change actually contradicts to the specification of JTextField.
>
> Check the specification:
> /**
> * Constructs a new <code>JTextField</code> that uses the given text
> * storage model and the given number of columns.
> * @param columns the number of columns to use to calculate
> * the preferred width >= 0; if <code>columns</code>
> * is set to zero, the preferred width will be whatever
> * naturally results from the component implementation
> */
> public JTextField(Document doc, String text, int columns) {
>
> /**
> * Returns the preferred size <code>Dimensions</code> needed for this
> * <code>TextField</code>. If a non-zero number of columns has been
> * set, the width is set to the columns multiplied by
> * the column width.
> *
> * @return the dimension of this textfield
> */
> public Dimension getPreferredSize() {
>
> Note that this class explicitly states in two places that if the columns are set then they will be used for calculation of the preferred size. So such change will require a javadoc update.
>
> PS: I wonder why the same functionality in JTextArea is specified and implemented differently....
>
>
>
> On 18/01/16 13:46, Prem Balakrishnan wrote:
>> Hi,
>>
>> Please review fix for JDK9,
>>
>> *Bug:*https://bugs.openjdk.java.net/browse/JDK-8146320
>>
>> *Webrev:*http://cr.openjdk.java.net/~rchamyal/prem/8146320/webrev.00/
>>
>> *Issue:*
>>
>> JTextField ignores setPreferredSize when having columns
>>
>> *Cause:*
>>
>> JTextField setPreferredSize is not actually ignored , when column
>> value is set>0.
>>
>> While retrieving the values set using getPreferredSize(), wrong
>> values were returned.
>>
>> *Fix:*
>>
>> Check added, if Column>0 and if Preferred size is not set after
>> setting columns, while retrieving values.
>>
>> Regards,
>> Prem
>>
>
>
--
Best regards, Sergey.
More information about the swing-dev
mailing list