< prev index next >
src/java.desktop/share/classes/java/awt/List.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1995, 2015, 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) 1995, 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
*** 150,160 ****
*
* @serial
* @see #getSelectedIndexes()
* @see #getSelectedIndex()
*/
! int selected[] = new int[0];
/**
* This variable contains the value that will be used
* when trying to make a particular list item visible.
*
--- 150,160 ----
*
* @serial
* @see #getSelectedIndexes()
* @see #getSelectedIndex()
*/
! int[] selected = new int[0];
/**
* This variable contains the value that will be used
* when trying to make a particular list item visible.
*
*** 319,329 ****
* @see #deselect
* @see #isIndexSelected
* @since 1.1
*/
public synchronized String[] getItems() {
! String itemCopies[] = new String[items.size()];
items.copyInto(itemCopies);
return itemCopies;
}
/**
--- 319,329 ----
* @see #deselect
* @see #isIndexSelected
* @since 1.1
*/
public synchronized String[] getItems() {
! String[] itemCopies = new String[items.size()];
items.copyInto(itemCopies);
return itemCopies;
}
/**
*** 486,496 ****
* @see #select
* @see #deselect
* @see #isIndexSelected
*/
public synchronized int getSelectedIndex() {
! int sel[] = getSelectedIndexes();
return (sel.length == 1) ? sel[0] : -1;
}
/**
* Gets the selected indexes on the list.
--- 486,496 ----
* @see #select
* @see #deselect
* @see #isIndexSelected
*/
public synchronized int getSelectedIndex() {
! int[] sel = getSelectedIndexes();
return (sel.length == 1) ? sel[0] : -1;
}
/**
* Gets the selected indexes on the list.
*** 532,543 ****
* @see #select
* @see #deselect
* @see #isIndexSelected
*/
public synchronized String[] getSelectedItems() {
! int sel[] = getSelectedIndexes();
! String str[] = new String[sel.length];
for (int i = 0 ; i < sel.length ; i++) {
str[i] = getItem(sel[i]);
}
return str;
}
--- 532,543 ----
* @see #select
* @see #deselect
* @see #isIndexSelected
*/
public synchronized String[] getSelectedItems() {
! int[] sel = getSelectedIndexes();
! String[] str = new String[sel.length];
for (int i = 0 ; i < sel.length ; i++) {
str[i] = getItem(sel[i]);
}
return str;
}
*** 600,610 ****
if (!alreadySelected) {
if (!multipleMode) {
selected = new int[1];
selected[0] = index;
} else {
! int newsel[] = new int[selected.length + 1];
System.arraycopy(selected, 0, newsel, 0,
selected.length);
newsel[selected.length] = index;
selected = newsel;
}
--- 600,610 ----
if (!alreadySelected) {
if (!multipleMode) {
selected = new int[1];
selected[0] = index;
} else {
! int[] newsel = new int[selected.length + 1];
System.arraycopy(selected, 0, newsel, 0,
selected.length);
newsel[selected.length] = index;
selected = newsel;
}
*** 634,644 ****
}
}
for (int i = 0 ; i < selected.length ; i++) {
if (selected[i] == index) {
! int newsel[] = new int[selected.length - 1];
System.arraycopy(selected, 0, newsel, 0, i);
System.arraycopy(selected, i+1, newsel, i, selected.length - (i+1));
selected = newsel;
return;
}
--- 634,644 ----
}
}
for (int i = 0 ; i < selected.length ; i++) {
if (selected[i] == index) {
! int[] newsel = new int[selected.length - 1];
System.arraycopy(selected, 0, newsel, 0, i);
System.arraycopy(selected, i+1, newsel, i, selected.length - (i+1));
selected = newsel;
return;
}
*** 667,677 ****
* @deprecated As of JDK version 1.1,
* replaced by {@code isIndexSelected(int)}.
*/
@Deprecated
public boolean isSelected(int index) {
! int sel[] = getSelectedIndexes();
for (int i = 0 ; i < sel.length ; i++) {
if (sel[i] == index) {
return true;
}
}
--- 667,677 ----
* @deprecated As of JDK version 1.1,
* replaced by {@code isIndexSelected(int)}.
*/
@Deprecated
public boolean isSelected(int index) {
! int[] sel = getSelectedIndexes();
for (int i = 0 ; i < sel.length ; i++) {
if (sel[i] == index) {
return true;
}
}
*** 1491,1501 ****
* Clears the selection in the object, so that nothing in the
* object is selected.
*/
public void clearAccessibleSelection() {
synchronized(List.this) {
! int selectedIndexes[] = List.this.getSelectedIndexes();
if (selectedIndexes == null)
return;
for (int i = selectedIndexes.length - 1; i >= 0; i--) {
List.this.deselect(selectedIndexes[i]);
}
--- 1491,1501 ----
* Clears the selection in the object, so that nothing in the
* object is selected.
*/
public void clearAccessibleSelection() {
synchronized(List.this) {
! int[] selectedIndexes = List.this.getSelectedIndexes();
if (selectedIndexes == null)
return;
for (int i = selectedIndexes.length - 1; i >= 0; i--) {
List.this.deselect(selectedIndexes[i]);
}
< prev index next >