
no.tornado.databinding.model.ListComboBoxModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of databinding Show documentation
Show all versions of databinding Show documentation
Swing Data Binding is a powerful, fast, light and simple data binding framework for Java.
The newest version!
package no.tornado.databinding.model;
import javax.swing.*;
import javax.swing.event.ListDataListener;
import java.util.List;
public class ListComboBoxModel implements ComboBoxModel {
private Object selected;
private List list;
public ListComboBoxModel(List list) {
this.list = list;
}
public void setSelectedItem(Object anItem) {
if (anItem == null)
selected = null;
else {
int idx = list.indexOf(anItem);
// Use value from list if this object matches
if (idx > -1)
selected = list.get(idx);
else
selected = anItem;
}
}
public Object getSelectedItem() {
return selected;
}
public int getSize() {
return list.size();
}
public Object getElementAt(int index) {
return list.get(index);
}
public void addListDataListener(ListDataListener l) {
}
public void removeListDataListener(ListDataListener l) {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy