--- old/src/java.desktop/share/classes/javax/swing/DefaultListModel.java 2018-04-09 16:54:41.431753000 +0530 +++ new/src/java.desktop/share/classes/javax/swing/DefaultListModel.java 2018-04-09 16:54:39.093491700 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,10 +26,9 @@ package javax.swing; import java.util.Vector; +import java.util.Collection; import java.util.Enumeration; -import javax.swing.event.*; - /** * This class loosely implements the java.util.Vector @@ -539,11 +538,44 @@ fireIntervalRemoved(this, fromIndex, toIndex); } - /* - public void addAll(Collection c) { + /** + * Adds all of the elements present in the collection to the list. + * + * @param c the collection which contains the elements to add. + */ + public void addAll(Collection c) { + if (c.isEmpty()) { + return; + } + + int startIndex = getSize(); + + delegate.addAll(c); + fireIntervalAdded(this, startIndex, getSize() - 1); } - public void addAll(int index, Collection c) { + /** + * Adds all of the elements present in the collection, starting + * from the index specified. + *

+ * Throws as IllegalArgumentException if the + * index is invalid. + * + * @param index the index from which to start adding elements from. + * @param c the collection which contains the elements to add + * @exception IllegalArgumentException if c doesn't + * fall in the rang of the list. + */ + public void addAll(int index, Collection c) { + if (index < 0 || index > getSize()) { + throw new IllegalArgumentException( + "index number must be >=0 and <= number of elements in the list."); + } + if (c.isEmpty()) { + return; + } + + delegate.addAll(index, c); + fireIntervalAdded(this, index, index + c.size() - 1); } - */ }