< prev index next >
src/java.desktop/share/classes/javax/swing/DefaultComboBoxModel.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1998, 2014, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 22,33 ****
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing;
! import java.util.*;
!
import java.io.Serializable;
/**
* The default model for combo boxes.
*
--- 22,33 ----
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing;
! import java.util.Collection;
! import java.util.Vector;
import java.io.Serializable;
/**
* The default model for combo boxes.
*
*** 175,180 ****
--- 175,222 ----
fireIntervalRemoved(this, firstIndex, lastIndex);
} else {
selectedObject = null;
}
}
+
+ /**
+ * Adds all of the elements present in the collection.
+ *
+ * @param c the collection which contains the elements to add
+ * @throws NullPointerException if {@code c} is null
+ */
+ public void addAll(Collection<? extends E> c) {
+ if (c.isEmpty()) {
+ return;
+ }
+
+ int startIndex = getSize();
+
+ objects.addAll(c);
+ fireIntervalAdded(this, startIndex, getSize() - 1);
+ }
+
+ /**
+ * Adds all of the elements present in the collection, starting
+ * from the specified index.
+ *
+ * @param index index at which to insert the first element from the
+ * specified collection
+ * @param c the collection which contains the elements to add
+ * @throws ArrayIndexOutOfBoundsException if {@code index} does not
+ * fall within the range of number of elements currently held
+ * @throws NullPointerException if {@code c} is null
+ */
+ public void addAll(int index, Collection<? extends E> c) {
+ if (index < 0 || index > getSize()) {
+ throw new ArrayIndexOutOfBoundsException("index out of range: " +
+ index);
+ }
+
+ if (c.isEmpty()) {
+ return;
+ }
+
+ objects.addAll(index, c);
+ fireIntervalAdded(this, index, index + c.size() - 1);
+ }
}
< prev index next >