Skip to content

Commit

Permalink
update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudFofou committed Nov 22, 2024
1 parent c5bbd62 commit f1a23ba
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
import javax.swing.event.EventListenerList;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;

Expand Down Expand Up @@ -1183,9 +1185,23 @@ public void valueChanged(ListSelectionEvent e) {
});
DefaultCellEditor cellEditor = new DefaultCellEditor(jTextFieldEditor);
jTableInventoryRow.setDefaultEditor(Integer.class, cellEditor);
model.addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
updateListFromModel();
}
});
}
return jTableInventoryRow;
}
private void updateListFromModel() {
for (int i = 0; i < model.getRowCount(); i++) {
jTableInventoryRow.convertRowIndexToView(i);
}
for (int i = 0; i < model.getColumnCount(); i++) {
jTableInventoryRow.convertColumnIndexToView(i);
}
}

class EnabledTableCellRenderer extends DefaultTableCellRenderer {

Expand Down

0 comments on commit f1a23ba

Please sign in to comment.