예제 #1
0
 public void addElement(Object o) {
   Comparable a = (Comparable) o;
   int i = 0;
   for (i = 0; i < getSize(); i++) {
     if (a.compareTo(getElementAt(i)) < 0) {
       break;
     }
   }
   super.add(i, o);
 }
  private void updateList() {
    list.removeAll();
    DefaultListModel model = new DefaultListModel();
    if (shapefile == null) {
      return;
    }
    if (new File(shapefile.replace(".shp", ".dbf")).exists()) {

      try {
        AttributeTable table = new AttributeTable(shapefile.replace(".shp", ".dbf"));
        DBFField[] fields = table.getAllFields();
        for (DBFField field : fields) {
          model.add(model.size(), field.getName());
        }
      } catch (Exception e) {

      }
    } else {
      model.add(0, "");
    }
    list.setModel(model);
  }