i have a Java program which has a table and a table model. Each cell is a JTextField with a mouselistener on it.
public class ButtonCellEditor extends AbstractCellEditor implements TableCellEditor, ActionListener, MouseListener{
private JTextField lab;
public ButtonCellEditor(MonthManager mm) {
super();
lab=new JTextField();
lab.addMouseListener(this);
}
when i click the cell it opens another JDialog to edit cell background information which calculates sum of different values
@Override
public void mouseClicked(MouseEvent arg0) {
CellDialog bd = new CellDialog(mm,mm.getMonths().get(column));
bd.openDialog();
//lab.setText("34");
}
In this Dialog I have some Components to calculate Data. One is an apply button which shall update the cell information that was clicked (and sometimes also other cells) If this apply buton is clicked an actionlistener is called which updates at least the cell i have clicked on via the table model
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() instanceof JButton){
model.setValueAt(cellSum, i, columnIndex); // <-- Cell where I clicked on
model.setValueAt(anotherSum, i+1, columnIndex); // <-- another cell
}
}
What happens now is that the other cell gets updated but the cell where i clicked on not (after closing the dialog). The code is only small snippets showing the basic thing. The overall code would be too much here and only irritating since im quite sure that it has to do with the cell event. Somehow the table content cannot be changed while it is focused or as long as it is handling the mouselistener event. If I enable he row above "lab.setText("34");" this gets writen into the cell when i close the dialog, but never the value i wrote into the table model.
Setting the Dialog no non-modal doesnt change this. Only advantage is that the other cells get updated while the dialog is still open, but not the clicked cell. Best case would be if I could update all cells as non-modal to see the changes live.
Hope I explained my issue well and all needed information is there.
Please let me know if you have an idea since after several hours trying different things and searchig in the net I couldnt solve this yet.
Thanks a lot!
Tobi