本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
}