I have an object called "Book" with columns like title, author, bookID etc... created on Microsoft SQL Server. Everything is connected with Netbeans and works fine. I also have the filter/search option which works well too but I want to have a combo box filled with Book columns like title, author etc where I want to select a column and search only within them.
I already have a class
called BookComboBoxModel
that returns books (code below) but I want the book columns from that table and not the Book.toString()
method on comboBox
//this is my book combo model that returns books into combobox
public class BookComboBoxModel extends AbstractListModel<Book> implements ComboBoxModel<Book> {
private List <Book> data;
private Book selectedItem;
public BookComboBoxModel(List<Book> data) {
this.data = data;
}
public BookComboBoxModel() {
}
public void add(List<Book> data) {
this.data = data;
}
@Override
public int getSize() {
return data.size();
}
@Override
public Book getElementAt(int index) {
return data.get(index);
}
@Override
public void setSelectedItem(Object anItem) {
selectedItem = (Book) anItem;
}
@Override
public Object getSelectedItem() {
return selectedItem;
}
}