コード例 #1
0
  // Add/Insert
  public int add(Script script) {
    // Find the correct spot to add it alphabetically
    int i, limit;
    for (i = 0, limit = scripts.size(); i < limit; i++) {
      Script scriptTemp = (Script) scripts.get(i);
      if (scriptTemp.getName().compareTo(script.getName()) >= 0) {
        break;
      }
    }

    scripts.add(i, script);

    // Update the table
    fireTableRowsInserted(i, i);

    return i;
  }
コード例 #2
0
  public int indexOf(String name) {
    for (int i = 0, limit = scripts.size(); i < limit; i++) {
      Script script = get(i);
      if (script.getName().equals(name)) {
        return i;
      }
    }

    return -1;
  }