Beispiel #1
0
 /**
  * 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 void remove(int index) throws IllegalArgumentException {
   items.removeElementAt(index);
   if (peer != null) {
     ListPeer l = (ListPeer) peer;
     l.delItems(index, index);
   }
 }
Beispiel #2
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;
 }
Beispiel #3
0
 /** Deletes all of the items from the list. */
 public synchronized void removeAll() {
   items.clear();
   if (peer != null) {
     ListPeer l = (ListPeer) peer;
     l.removeAll();
   }
 }
Beispiel #4
0
 /**
  * This method enables or disables multiple selection mode for this list.
  *
  * @param multipleMode <code>true</code> to enable multiple mode, <code>false</code> otherwise.
  */
 public void setMultipleMode(boolean multipleMode) {
   this.multipleMode = multipleMode;
   if (peer != null) {
     ListPeer l = (ListPeer) peer;
     l.setMultipleMode(multipleMode);
   }
 }
Beispiel #5
0
  /**
   * 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 int getSelectedIndex() {
    if (peer != null) {
      ListPeer l = (ListPeer) peer;
      selected = l.getSelectedIndexes();
    }

    if (selected == null || selected.length > 1) return -1;
    return selected[0];
  }
Beispiel #6
0
  /**
   * 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 void add(String item, int index) {
    if ((index == -1) || (index >= items.size())) items.addElement(item);
    else items.insertElementAt(item, index);

    if (peer != null) {
      ListPeer l = (ListPeer) peer;
      l.add(item, index);
    }
  }
Beispiel #7
0
  /**
   * This method ensures that the item at the specified index is visible.
   *
   * @exception IllegalArgumentException If the specified index is out of range.
   */
  public synchronized void makeVisible(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);
    }
  }
Beispiel #8
0
  /**
   * 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 void delItems(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);
    }
  }
Beispiel #9
0
 /**
  * Makes the item at the specified index not selected.
  *
  * @param index The index of the item to unselect.
  */
 public synchronized void deselect(int index) {
   ListPeer lp = (ListPeer) getPeer();
   if (lp != null) lp.deselect(index);
 }
Beispiel #10
0
 /**
  * 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.
  */
 public Dimension getPreferredSize(int rows) {
   ListPeer lp = (ListPeer) getPeer();
   if (lp != null) return (lp.preferredSize(rows));
   else return (new Dimension(0, 0));
 }
Beispiel #11
0
 /**
  * Returns the minimum size of this component assuming it had the specified number of rows.
  *
  * @param rows The number of rows to size for.
  * @return The minimum size of this component.
  */
 public Dimension getMinimumSize(int rows) {
   ListPeer lp = (ListPeer) getPeer();
   if (lp != null) return (lp.minimumSize(rows));
   else return (new Dimension(0, 0));
 }