<Swing Dev> [11][JDK-4842658] RFR: DefaultListModel and DefaultComboBoxModel should support addAll (Collection c)
Krishna Addepalli
krishna.addepalli at oracle.com
Fri Apr 13 05:34:18 UTC 2018
Hi Sergey,
Yes, I saw those methods in DefaultListModel, but it had add method, which is why I have added "addAll" method there. In the case of DefaultComboBoxModel, the add method is "addElement", which is why I chose to rename the plural methods to "addElements", and "addElementsAt".
However, I'm ok to change the method names to addAll.
Thanks,
Krishna
-----Original Message-----
From: Sergey Bylokhov
Sent: Friday, April 13, 2018 2:59 AM
To: Krishna Addepalli <krishna.addepalli at oracle.com>; Andrej Golovnin <andrej.golovnin at gmail.com>
Cc: swing-dev at openjdk.java.net
Subject: Re: <Swing Dev> [11][JDK-4842658] RFR: DefaultListModel and DefaultComboBoxModel should support addAll (Collection c)
On 10/04/2018 05:43, Krishna Addepalli wrote:
> - Why in one class you use addElements/addElementsAt names and in another addAll?
> In the DefaultComboBoxModel, the functions to add a single element are named as addElement, addElementAt.
> To keep with that convention, I named the apis appropriately.
DefaultListModel also has getElementAt()/addElement()/removeElement()
etc. I can guess this is because it is a wrapper of Vector which has the same methods. But in jdk1.2(when Collection framework was added) some additional methods were added to DefaultListModel like
clear()/get()/set()/add() etc.
I don't urge to change the existing methods in DefaultComboBoxModel but it would be good to use one common name pattern for models which is used in Collection framework. Any thoughts?
--
Best regards, Sergey.
More information about the swing-dev
mailing list