--- old/src/java.desktop/share/classes/javax/swing/DefaultComboBoxModel.java 2018-04-07 16:18:16.497518100 +0530 +++ new/src/java.desktop/share/classes/javax/swing/DefaultComboBoxModel.java 2018-04-07 16:18:12.794674100 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -24,8 +24,8 @@ */ package javax.swing; -import java.util.*; - +import java.util.Collection; +import java.util.Vector; import java.io.Serializable; /** @@ -177,4 +177,47 @@ selectedObject = null; } } + + /** + * Adds all of the elements present in the collection. + *

+ * + * @param c the collection which contains the elements to add. + */ + public void addElements(Collection c) { + if (c.isEmpty()) { + return; + } + + int startIndex = getSize(); + + objects.addAll(c); + fireIntervalAdded(this, startIndex, getSize()); + } + + /** + * Add all of the elements present in the collection, starting + * from the index specified. + *

+ * Throws an IllegalArgumentException + * if the index was 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 range of the list. + */ + public void addElementsAt(int index, Collection c) { + if (index < 0 || index > getSize()) { + throw new IllegalArgumentException( + "index must be >=0 and <= number of elements in the combobox."); + } + + if (c.isEmpty()) { + return; + } + + objects.addAll(index, c); + fireIntervalAdded(this, index, index + c.size()); + } }