Java 类java.awt.peer.ListPeer 实例源码

项目:OpenJSharp    文件:List.java   
/**
 * @deprecated      replaced by <code>add(String, int)</code>.
 */
@Deprecated
public synchronized void addItem(String item, int index) {
    if (index < -1 || index >= items.size()) {
        index = -1;
    }

    if (item == null) {
        item = "";
    }

    if (index == -1) {
        items.addElement(item);
    } else {
        items.insertElementAt(item, index);
    }

    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.add(item, index);
    }
}
项目:OpenJSharp    文件:List.java   
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    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;
        }
    }
}
项目:jdk8u-jdk    文件:List.java   
/**
 * @deprecated      replaced by <code>add(String, int)</code>.
 */
@Deprecated
public synchronized void addItem(String item, int index) {
    if (index < -1 || index >= items.size()) {
        index = -1;
    }

    if (item == null) {
        item = "";
    }

    if (index == -1) {
        items.addElement(item);
    } else {
        items.insertElementAt(item, index);
    }

    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.add(item, index);
    }
}
项目:jdk8u-jdk    文件:List.java   
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    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;
        }
    }
}
项目:jdk8u-jdk    文件:ListRepaint.java   
void test() {
    select(0);
    ((ListPeer) getPeer()).select(getSelectedIndex());

    setFont(null);
    setFont(getFont());
    getPeer().setFont(getFont());

    setBackground(null);
    setBackground(getBackground());
    getPeer().setBackground(getBackground());

    setForeground(null);
    setForeground(getForeground());
    getPeer().setForeground(getForeground());

    setEnabled(isEnabled());
    getPeer().setEnabled(isEnabled());
}
项目:openjdk-jdk10    文件:List.java   
/**
 * Adds the specified item to the list
 * at the position indicated by the index.
 *
 * @param  item the item to be added
 * @param  index the position at which to add the item
 * @deprecated replaced by {@code add(String, int)}.
 */
@Deprecated
public synchronized void addItem(String item, int index) {
    if (index < -1 || index >= items.size()) {
        index = -1;
    }

    if (item == null) {
        item = "";
    }

    if (index == -1) {
        items.addElement(item);
    } else {
        items.insertElementAt(item, index);
    }

    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.add(item, index);
    }
}
项目:openjdk-jdk10    文件:List.java   
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    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;
        }
    }
}
项目:openjdk9    文件:List.java   
/**
 * Adds the specified item to the list
 * at the position indicated by the index.
 *
 * @param  item the item to be added
 * @param  index the position at which to add the item
 * @deprecated replaced by {@code add(String, int)}.
 */
@Deprecated
public synchronized void addItem(String item, int index) {
    if (index < -1 || index >= items.size()) {
        index = -1;
    }

    if (item == null) {
        item = "";
    }

    if (index == -1) {
        items.addElement(item);
    } else {
        items.insertElementAt(item, index);
    }

    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.add(item, index);
    }
}
项目:openjdk9    文件:List.java   
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    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;
        }
    }
}
项目:Java8CN    文件:List.java   
/**
 * @deprecated      replaced by <code>add(String, int)</code>.
 */
@Deprecated
public synchronized void addItem(String item, int index) {
    if (index < -1 || index >= items.size()) {
        index = -1;
    }

    if (item == null) {
        item = "";
    }

    if (index == -1) {
        items.addElement(item);
    } else {
        items.insertElementAt(item, index);
    }

    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.add(item, index);
    }
}
项目:Java8CN    文件:List.java   
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    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;
        }
    }
}
项目:jdk8u_jdk    文件:List.java   
/**
 * @deprecated      replaced by <code>add(String, int)</code>.
 */
@Deprecated
public synchronized void addItem(String item, int index) {
    if (index < -1 || index >= items.size()) {
        index = -1;
    }

    if (item == null) {
        item = "";
    }

    if (index == -1) {
        items.addElement(item);
    } else {
        items.insertElementAt(item, index);
    }

    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.add(item, index);
    }
}
项目:jdk8u_jdk    文件:List.java   
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    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;
        }
    }
}
项目:jdk8u_jdk    文件:ListRepaint.java   
void test() {
    select(0);
    ((ListPeer) getPeer()).select(getSelectedIndex());

    setFont(null);
    setFont(getFont());
    getPeer().setFont(getFont());

    setBackground(null);
    setBackground(getBackground());
    getPeer().setBackground(getBackground());

    setForeground(null);
    setForeground(getForeground());
    getPeer().setForeground(getForeground());

    setEnabled(isEnabled());
    getPeer().setEnabled(isEnabled());
}
项目:lookaside_java-1.8.0-openjdk    文件:List.java   
/**
 * @deprecated      replaced by <code>add(String, int)</code>.
 */
@Deprecated
public synchronized void addItem(String item, int index) {
    if (index < -1 || index >= items.size()) {
        index = -1;
    }

    if (item == null) {
        item = "";
    }

    if (index == -1) {
        items.addElement(item);
    } else {
        items.insertElementAt(item, index);
    }

    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.add(item, index);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:List.java   
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    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;
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:ListRepaint.java   
void test() {
    select(0);
    ((ListPeer) getPeer()).select(getSelectedIndex());

    setFont(null);
    setFont(getFont());
    getPeer().setFont(getFont());

    setBackground(null);
    setBackground(getBackground());
    getPeer().setBackground(getBackground());

    setForeground(null);
    setForeground(getForeground());
    getPeer().setForeground(getForeground());

    setEnabled(isEnabled());
    getPeer().setEnabled(isEnabled());
}
项目:javify    文件:List.java   
/**
 * Adds the specified item to the specified location in the list.
 * If the desired index is -1 or greater than the number of rows
 * in the list, then the item is added to the end.
 *
 * @param item The item to add to the list.
 * @param index The location in the list to add the item, or -1 to add
 * to the end.
 *
 * @deprecated Use add() instead.
 */
public void addItem(String item, int index)
{
  if (item == null)
    item = "";

  if (index < -1)
    index = -1;

  if ((index == -1) || (index >= items.size ()))
    items.addElement (item);
  else
    items.insertElementAt(item, index);

  ListPeer peer = (ListPeer) getPeer();
  if (peer != null)
    peer.add (item, index);
}
项目:javify    文件:List.java   
/**
 * Deletes the item at the specified index.
 *
 * @param index The index of the item to delete.
 *
 * @exception IllegalArgumentException If the index is not valid
 *
 * @deprecated
 */
public void delItem(int index) throws IllegalArgumentException
{
  boolean selected = false;
  if (isSelected(index))
    {
      selected = true;
      deselect(index);
    }

  items.removeElementAt (index);

  if (selected)
    select(index);

  ListPeer peer = (ListPeer) getPeer();
  if (peer != null)
    peer.delItems (index, index);
}
项目:javify    文件:List.java   
/**
 * Replaces the item at the specified index with the specified item.
 *
 * @param item The new item value.
 * @param index The index of the item to replace.
 *
 * @exception ArrayIndexOutOfBoundsException If the index is not valid.
 */
public synchronized void replaceItem(String item, int index)
  throws ArrayIndexOutOfBoundsException
{
  if ((index < 0) || (index >= items.size()))
    throw new ArrayIndexOutOfBoundsException("Bad list index: " + index);

  items.insertElementAt(item, index + 1);
  items.removeElementAt (index);

  if (peer != null)
    {
      ListPeer l = (ListPeer) peer;

      /* We add first and then remove so that the selected
         item remains the same */
      l.add (item, index + 1);
      l.delItems (index, index);
    }
}
项目:javify    文件:List.java   
/**
 * Makes the item at the specified index not selected.
 *
 * @param index The index of the item to unselect.
 */
public synchronized void deselect(int index)
{
  if (isSelected(index))
    {
      ListPeer lp = (ListPeer)getPeer();
      if (lp != null)
        lp.deselect(index);

      int[] temp = new int[selected.length - 1];
      for (int i = 0; i < temp.length; i++)
        {
          if (selected[i] != index)
            temp[i] = selected[i];
          else
            {
              System.arraycopy(selected, i + 1, temp, i,
                               selected.length - i - 1);
              break;
            }
        }
      selected = temp;
    }
}
项目:jvm-stm    文件:List.java   
/**
 * Adds the specified item to the specified location in the list.
 * If the desired index is -1 or greater than the number of rows
 * in the list, then the item is added to the end.
 *
 * @param item The item to add to the list.
 * @param index The location in the list to add the item, or -1 to add
 * to the end.
 *
 * @deprecated Use add() instead.
 */
public void addItem(String item, int index)
{
  if (item == null)
    item = ""; 

  if (index < -1)
    index = -1;

  if ((index == -1) || (index >= items.size ()))
    items.addElement (item);
  else
    items.insertElementAt(item, index);

  ListPeer peer = (ListPeer) getPeer();
  if (peer != null)
    peer.add (item, index);
}
项目:jvm-stm    文件:List.java   
/**
 * Deletes the item at the specified index.
 *
 * @param index The index of the item to delete.
 *
 * @exception IllegalArgumentException If the index is not valid
 *
 * @deprecated
 */
public void delItem(int index) throws IllegalArgumentException
{
  boolean selected = false;
  if (isSelected(index))
    {
      selected = true;
      deselect(index);   
    }

  items.removeElementAt (index);

  if (selected)
    select(index);

  ListPeer peer = (ListPeer) getPeer();
  if (peer != null)
    peer.delItems (index, index);
}
项目:jvm-stm    文件:List.java   
/**
 * Replaces the item at the specified index with the specified item.
 *
 * @param item The new item value.
 * @param index The index of the item to replace.
 *
 * @exception ArrayIndexOutOfBoundsException If the index is not valid.
 */
public synchronized void replaceItem(String item, int index) 
  throws ArrayIndexOutOfBoundsException
{
  if ((index < 0) || (index >= items.size()))
    throw new ArrayIndexOutOfBoundsException("Bad list index: " + index);

  items.insertElementAt(item, index + 1);
  items.removeElementAt (index);

  if (peer != null)
    {
      ListPeer l = (ListPeer) peer;

      /* We add first and then remove so that the selected
  item remains the same */
      l.add (item, index + 1);
      l.delItems (index, index);
    }
}
项目:jvm-stm    文件:List.java   
/**
 * Makes the item at the specified index not selected.
 *
 * @param index The index of the item to unselect.
 */
public synchronized void deselect(int index)
{
  if (isSelected(index))
    {
      ListPeer lp = (ListPeer)getPeer();
      if (lp != null)
        lp.deselect(index);

      int[] temp = new int[selected.length - 1];
      for (int i = 0; i < temp.length; i++)
        {
          if (selected[i] != index)
            temp[i] = selected[i];
          else
            {
              System.arraycopy(selected, i + 1, temp, i, 
                               selected.length - i - 1);
              break;
            }
        }
      selected = temp;
    }
}
项目:VarJ    文件:List.java   
/**
    * @deprecated      replaced by <code>add(String, int)</code>.
    */
   @Deprecated
   public synchronized void addItem(String item, int index) {
if (index < -1 || index >= items.size()) {
    index = -1;
}

       if (item == null) {
           item = "";
       }

if (index == -1) {
    items.addElement(item);
} else {
    items.insertElementAt(item, index);
}

ListPeer peer = (ListPeer)this.peer;
if (peer != null) {
    peer.addItem(item, index);
}
   }
项目:VarJ    文件:List.java   
/**
    * Deselects the item at the specified index.
    * <p>
    * Note that passing out of range parameters is invalid, 
    * and will result in unspecified behavior.  
    * <p>
    * If the item at the specified index is not selected,
    * then the operation is ignored.
    * @param        index the position of the item to deselect
    * @see          #select
    * @see          #getSelectedItem
    * @see          #isIndexSelected
    */
   public synchronized void deselect(int index) {
ListPeer peer = (ListPeer)this.peer;
if (peer != null) {
    peer.deselect(index);
}

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;
    }
}
   }
项目:jdk-1.7-annotated    文件:List.java   
/**
 * @deprecated      replaced by <code>add(String, int)</code>.
 */
@Deprecated
public synchronized void addItem(String item, int index) {
    if (index < -1 || index >= items.size()) {
        index = -1;
    }

    if (item == null) {
        item = "";
    }

    if (index == -1) {
        items.addElement(item);
    } else {
        items.insertElementAt(item, index);
    }

    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.add(item, index);
    }
}
项目:jdk-1.7-annotated    文件:List.java   
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    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;
        }
    }
}
项目:infobip-open-jdk-8    文件:List.java   
/**
 * @deprecated      replaced by <code>add(String, int)</code>.
 */
@Deprecated
public synchronized void addItem(String item, int index) {
    if (index < -1 || index >= items.size()) {
        index = -1;
    }

    if (item == null) {
        item = "";
    }

    if (index == -1) {
        items.addElement(item);
    } else {
        items.insertElementAt(item, index);
    }

    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.add(item, index);
    }
}
项目:infobip-open-jdk-8    文件:List.java   
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    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;
        }
    }
}
项目:infobip-open-jdk-8    文件:ListRepaint.java   
void test() {
    select(0);
    ((ListPeer) getPeer()).select(getSelectedIndex());

    setFont(null);
    setFont(getFont());
    getPeer().setFont(getFont());

    setBackground(null);
    setBackground(getBackground());
    getPeer().setBackground(getBackground());

    setForeground(null);
    setForeground(getForeground());
    getPeer().setForeground(getForeground());

    setEnabled(isEnabled());
    getPeer().setEnabled(isEnabled());
}
项目:jdk8u-dev-jdk    文件:List.java   
/**
 * @deprecated      replaced by <code>add(String, int)</code>.
 */
@Deprecated
public synchronized void addItem(String item, int index) {
    if (index < -1 || index >= items.size()) {
        index = -1;
    }

    if (item == null) {
        item = "";
    }

    if (index == -1) {
        items.addElement(item);
    } else {
        items.insertElementAt(item, index);
    }

    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.add(item, index);
    }
}
项目:jdk8u-dev-jdk    文件:List.java   
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    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;
        }
    }
}
项目:jdk8u-dev-jdk    文件:ListRepaint.java   
void test() {
    select(0);
    ((ListPeer) getPeer()).select(getSelectedIndex());

    setFont(null);
    setFont(getFont());
    getPeer().setFont(getFont());

    setBackground(null);
    setBackground(getBackground());
    getPeer().setBackground(getBackground());

    setForeground(null);
    setForeground(getForeground());
    getPeer().setForeground(getForeground());

    setEnabled(isEnabled());
    getPeer().setEnabled(isEnabled());
}
项目:jdk7-jdk    文件:List.java   
/**
 * @deprecated      replaced by <code>add(String, int)</code>.
 */
@Deprecated
public synchronized void addItem(String item, int index) {
    if (index < -1 || index >= items.size()) {
        index = -1;
    }

    if (item == null) {
        item = "";
    }

    if (index == -1) {
        items.addElement(item);
    } else {
        items.insertElementAt(item, index);
    }

    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.add(item, index);
    }
}
项目:jdk7-jdk    文件:List.java   
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    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;
        }
    }
}
项目:openjdk-source-code-learn    文件:List.java   
/**
 * @deprecated      replaced by <code>add(String, int)</code>.
 */
@Deprecated
public synchronized void addItem(String item, int index) {
    if (index < -1 || index >= items.size()) {
        index = -1;
    }

    if (item == null) {
        item = "";
    }

    if (index == -1) {
        items.addElement(item);
    } else {
        items.insertElementAt(item, index);
    }

    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.add(item, index);
    }
}
项目:openjdk-source-code-learn    文件:List.java   
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    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;
        }
    }
}
项目:OLD-OpenJDK8    文件:List.java   
/**
 * @deprecated      replaced by <code>add(String, int)</code>.
 */
@Deprecated
public synchronized void addItem(String item, int index) {
    if (index < -1 || index >= items.size()) {
        index = -1;
    }

    if (item == null) {
        item = "";
    }

    if (index == -1) {
        items.addElement(item);
    } else {
        items.insertElementAt(item, index);
    }

    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.add(item, index);
    }
}