コード例 #1
0
ファイル: List.java プロジェクト: andreasbaumann/tomato
 /**
  * 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);
   }
 }
コード例 #2
0
ファイル: List.java プロジェクト: andreasbaumann/tomato
 /**
  * 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;
 }
コード例 #3
0
ファイル: List.java プロジェクト: andreasbaumann/tomato
 /** Deletes all of the items from the list. */
 public synchronized void removeAll() {
   items.clear();
   if (peer != null) {
     ListPeer l = (ListPeer) peer;
     l.removeAll();
   }
 }
コード例 #4
0
ファイル: List.java プロジェクト: andreasbaumann/tomato
 /**
  * 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);
   }
 }
コード例 #5
0
ファイル: List.java プロジェクト: andreasbaumann/tomato
  /**
   * 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];
  }
コード例 #6
0
ファイル: List.java プロジェクト: andreasbaumann/tomato
  /**
   * 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);
    }
  }
コード例 #7
0
ファイル: List.java プロジェクト: andreasbaumann/tomato
  /**
   * 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);
    }
  }
コード例 #8
0
ファイル: List.java プロジェクト: andreasbaumann/tomato
  /**
   * 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);
    }
  }
コード例 #9
0
ファイル: List.java プロジェクト: andreasbaumann/tomato
 /**
  * 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);
 }
コード例 #10
0
ファイル: List.java プロジェクト: andreasbaumann/tomato
 /**
  * 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));
 }
コード例 #11
0
ファイル: List.java プロジェクト: andreasbaumann/tomato
 /**
  * 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));
 }