2008-07-30 22:37:01 +00:00
|
|
|
|
|
|
|
package net.sourceforge.tuned.ui;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
|
|
|
import javax.swing.ListModel;
|
|
|
|
import javax.swing.event.ListDataListener;
|
|
|
|
|
|
|
|
|
|
|
|
public class ArrayListModel implements ListModel {
|
|
|
|
|
2009-02-10 19:37:32 +00:00
|
|
|
private final Object[] data;
|
2008-07-30 22:37:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
public ArrayListModel(Collection<? extends Object> data) {
|
2009-02-10 19:37:32 +00:00
|
|
|
this.data = data.toArray();
|
2008-07-30 22:37:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Object getElementAt(int index) {
|
2009-02-10 19:37:32 +00:00
|
|
|
return data[index];
|
2008-07-30 22:37:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getSize() {
|
2009-02-10 19:37:32 +00:00
|
|
|
return data.length;
|
2008-07-30 22:37:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void addListDataListener(ListDataListener l) {
|
|
|
|
// ignore, model is unmodifiable
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void removeListDataListener(ListDataListener l) {
|
|
|
|
// ignore, model is unmodifiable
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|