I have a table that displays the data: ID, NAME, CATEGORY, COMPANY. Data is retrieved from the database. I would like to add a ComboBox to the column CATEGORY. So as to be able to choose any category that they are in the database.
List<Item> item;
JTable itemTable = new JTable();
JScrollPane itemScroll = new JScrollPane();
DefaultTableModel itemmodel = new DefaultTableModel();
itemmodel.setRowCount(0);
item = model.getItem();
for (Item ite : item) {
itemmodel.addRow(new Object[] { ite.getId(), ite.getName(),
ite.getCategory(), ite.getCompany() });
}
item.clear();
Then I add the data to the JFrame properly and everything displays. I read the documentation, but I do not know how to use the examples in my case.
To display the same categories have separate jTable and data downloading via
tablemodel.setRowCount(0);
category = model.getCategory();
for (Category cat: categoryList) {
tablemodel
.addRow(new Object[] { cat.getId(), cat.getName() });
}
categoryList.clear();