当前位置: 首页>>代码示例>>Java>>正文


Java ListPeer.add方法代码示例

本文整理汇总了Java中java.awt.peer.ListPeer.add方法的典型用法代码示例。如果您正苦于以下问题:Java ListPeer.add方法的具体用法?Java ListPeer.add怎么用?Java ListPeer.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.peer.ListPeer的用法示例。


在下文中一共展示了ListPeer.add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addItem

import java.awt.peer.ListPeer; //导入方法依赖的package包/类
/**
 * @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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:List.java

示例2: addItem

import java.awt.peer.ListPeer; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:List.java

示例3: addItem

import java.awt.peer.ListPeer; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:vilie,项目名称:javify,代码行数:29,代码来源:List.java

示例4: replaceItem

import java.awt.peer.ListPeer; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:28,代码来源:List.java

示例5: addItem

import java.awt.peer.ListPeer; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:29,代码来源:List.java

示例6: replaceItem

import java.awt.peer.ListPeer; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:28,代码来源:List.java


注:本文中的java.awt.peer.ListPeer.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。