Reputation: 11
I created a TableColumn like this:
TableColumn ColonneArticle = jTableBonCommande.getColumnModel().getColumn(1);
I filled it from DB table named "Article"
List<Article> l = new ArrayList<Article>();
l= em.createNamedQuery("Article.findAll").getResultList();
TableColumn ColonneArticle = jTableBonCommande.getColumnModel().getColumn(1);
JComboBox comboBox = new JComboBox();
for (int i = 0; i < l.size(); i++) {
comboBox.addItem(l.get(i).getDesignationarticle());
}
ColonneArticle.setCellEditor(new DefaultCellEditor(comboBox));
Now i want to fill my jTable with selected "Article" credentials, so can i add a mouse click listener to a jCombobox in a jTable cell ?
Please Help !
Upvotes: 0
Views: 1215
Reputation: 347314
When a cell is updated, the TableModel#setValueAt
method is called. When this occurs for the first column, you should then load the values for the row based on the value passed to the this method
Upvotes: 1