All Downloads are FREE. Search and download functionalities are using the official Maven repository.

no.tornado.databinding.model.ListComboBoxModel Maven / Gradle / Ivy

Go to download

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