⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
{  return preferredSize (rows);}/*************************************************************************//**  * Returns the preferred size of this component assuming it had the specified  * number of rows.  *  * @param rows The number of rows to size for.  *  * @return The preferred size of this component.  *  * @deprecated This method is deprecated in favor of   * <code>getPreferredSize(int)</code>>  */public DimensionpreferredSize(int rows){  ListPeer peer = (ListPeer) getPeer ();  if (peer != null)    return peer.preferredSize (rows);  else    return new Dimension (0, 0);}/*************************************************************************//**  * This method adds the specified item to the end of the list.  *  * @param item The item to add to the list.  */public voidadd(String item){  add (item, -1);}/*************************************************************************//**  * This method adds the specified item to the end of the list.  *  * @param item The item to add to the list.  *  * @deprecated Use add() instead.  */public voidaddItem(String item){  addItem (item, -1);}/*************************************************************************//**  * 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.  */public voidadd(String item, int index){  addItem (item, index);}/*************************************************************************//**  * 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 voidaddItem(String item, int index){  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);}/*************************************************************************//**  * 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 voiddelItem(int index) throws IllegalArgumentException{  items.removeElementAt (index);  ListPeer peer = (ListPeer) getPeer ();  if (peer != null)    peer.delItems (index, index);}/*************************************************************************//**  * Deletes the item at the specified index.  *  * @param index The index of the item to delete.  *  * @exception IllegalArgumentException If the index is not valid  */public voidremove(int index) throws IllegalArgumentException{  delItem (index);}/*************************************************************************//**  * Deletes all items in the specified index range.  *  * @param start The beginning index of the range to delete.  * @param end The ending index of the range to delete.  *  * @exception IllegalArgumentException If the indexes are not valid  *  * @deprecated This method is deprecated for some unknown reason.  */public synchronized voiddelItems(int start, int end) throws IllegalArgumentException{  if ((start < 0) || (start >= items.size()))    throw new IllegalArgumentException("Bad list start index value: " + start);  if ((start < 0) || (start >= items.size()))    throw new IllegalArgumentException("Bad list start index value: " + start);  if (start > end)    throw new IllegalArgumentException("Start is greater than end!");  // We must run the loop in reverse direction.  for (int i = end; i >= start; --i)    items.removeElementAt (i);  if (peer != null)    {      ListPeer l = (ListPeer) peer;      l.delItems (start, end);    }}/*************************************************************************//**  * Deletes the first occurrence of the specified item from the list.  *  * @param item The item to delete.  *  * @exception IllegalArgumentException If the specified item does not exist.  */public synchronized voidremove(String item) throws IllegalArgumentException{  int index = items.indexOf(item);  if (index == -1)    throw new IllegalArgumentException("List element to delete not found");  remove(index);}/*************************************************************************//**  * Deletes all of the items from the list.  */public synchronized voidremoveAll(){  clear ();}/*************************************************************************//**  * Deletes all of the items from the list.  *   * @deprecated This method is deprecated in favor of <code>removeAll()</code>.  */public voidclear(){  items.clear();  ListPeer peer = (ListPeer) getPeer ();  if (peer != null)    peer.removeAll ();}/*************************************************************************//**  * 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 IllegalArgumentException If the index is not valid.  */public synchronized voidreplaceItem(String item, int index) throws IllegalArgumentException{  if ((index < 0) || (index >= items.size()))    throw new IllegalArgumentException("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);    }}/*************************************************************************//**  * Returns the index of the currently selected item.  -1 will be returned  * if there are no selected rows or if there are multiple selected rows.  *  * @return The index of the selected row.  */public synchronized intgetSelectedIndex(){  if (peer != null)    {      ListPeer l = (ListPeer) peer;      selected = l.getSelectedIndexes ();    }  if (selected == null || selected.length != 1)    return -1;  return selected[0];}/*************************************************************************//**  * Returns an array containing the indexes of the rows that are   * currently selected.  *  * @return A list of indexes of selected rows.  */public synchronized int[]getSelectedIndexes(){  if (peer != null)    {      ListPeer l = (ListPeer) peer;      selected = l.getSelectedIndexes ();    }  return selected;}/*************************************************************************//**  * Returns the item that is currently selected, or <code>null</code> if there   * is no item selected.  FIXME: What happens if multiple items selected?  *  * @return The selected item, or <code>null</code> if there is no  * selected item.  */public synchronized StringgetSelectedItem(){  int index = getSelectedIndex();  if (index == -1)    return(null);  return((String)items.elementAt(index));}/*************************************************************************//**  * Returns the list of items that are currently selected in this list.  *  * @return The list of currently selected items.  */public synchronized String[]getSelectedItems(){  int[] indexes = getSelectedIndexes();  if (indexes == null)    return(new String[0]);  String[] retvals = new String[indexes.length];  if (retvals.length > 0)    for (int i = 0 ; i < retvals.length; i++)       retvals[i] = (String)items.elementAt(indexes[i]);  return(retvals);}/*************************************************************************//**  * Returns the list of items that are currently selected in this list as  * an array of type <code>Object[]</code> instead of <code>String[]</code>.  *  * @return The list of currently selected items.  */public synchronized Object[]getSelectedObjects(){  int[] indexes = getSelectedIndexes();  if (indexes == null)    return(new Object[0]);  Object[] retvals = new Object[indexes.length];  if (retvals.length > 0)    for (int i = 0 ; i < retvals.length; i++)       retvals[i] = items.elementAt(indexes[i]);  return(retvals);}/*************************************************************************//**  * Tests whether or not the specified index is selected.  *  * @param index The index to test.  *  * @return <code>true</code> if the index is selected, <code>false</code>  * otherwise.  */public booleanisIndexSelected(int index){  return isSelected (index);}/*************************************************************************//**  * Tests whether or not the specified index is selected.  *  * @param index The index to test.  *  * @return <code>true</code> if the index is selected, <code>false</code>  * otherwise.  *  * @deprecated This method is deprecated in favor of  * <code>isIndexSelected(int)</code>.  */public booleanisSelected(int index){  int[] indexes = getSelectedIndexes ();  for (int i = 0; i < indexes.length; i++)    if (indexes[i] == index)      return true;  return false;}/*************************************************************************//**  * This method ensures that the item at the specified index is visible.  *  * @exception IllegalArgumentException If the specified index is out of  * range.  */public synchronized voidmakeVisible(int index) throws IllegalArgumentException{  if ((index < 0) || (index >= items.size()))    throw new IllegalArgumentException("Bad list index: " + index);  visibleIndex = index;  if (peer != null)    {      ListPeer l = (ListPeer) peer;      l.makeVisible (index);    }}/*************************************************************************//**  * Returns the index of the last item that was made visible via the  * <code>makeVisible()</code> method.  *  * @return The index of the last item made visible via the   * <code>makeVisible()</code> method.  */public intgetVisibleIndex()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -