本文整理汇总了Java中java.awt.peer.ListPeer类的典型用法代码示例。如果您正苦于以下问题:Java ListPeer类的具体用法?Java ListPeer怎么用?Java ListPeer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ListPeer类属于java.awt.peer包,在下文中一共展示了ListPeer类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: deselect
import java.awt.peer.ListPeer; //导入依赖的package包/类
/**
* 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;
}
}
}
示例3: test
import java.awt.peer.ListPeer; //导入依赖的package包/类
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());
}
示例4: 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);
}
}
示例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: delItem
import java.awt.peer.ListPeer; //导入依赖的package包/类
/**
* 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);
}
示例7: 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);
}
}
示例8: deselect
import java.awt.peer.ListPeer; //导入依赖的package包/类
/**
* 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;
}
}
示例9: 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);
}
示例10: delItem
import java.awt.peer.ListPeer; //导入依赖的package包/类
/**
* 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);
}
示例11: 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);
}
}
示例12: deselect
import java.awt.peer.ListPeer; //导入依赖的package包/类
/**
* 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;
}
}
示例13: 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.addItem(item, index);
}
}
示例14: deselect
import java.awt.peer.ListPeer; //导入依赖的package包/类
/**
* 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;
}
}
}