I have a JTable. Currently I have the following code:
table.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 1) {
JTable target = (JTable)e.getSource();
int row = target.getSelectedRow();
int value = Integer.parseInt( (String) table.getValueAt(row, 0));
int x = 0,y=0;
if (row==1) {x=582;y=483;} else if (row==2) {x=221;y=575;} else if (row==3) {x=231;y=435;}
boundaryFill4(x, y, value, 50);
my.setIcon(new ImageIcon(buffered));
}
}
});
But I need to make my JTable to update itself automatically as user types in new values. The mouse listener does not do exactly what I want. It would update as the user points the cursor to the JTable cell. I could not find any "input value update" listener in documentation.
I could use keyListener, but in that case I will need to add an "UPDATE" JButton, but I need the JTable to update itself automatically without JButton.
The third method would be to create an infinite update loop : while(true) { //update} But this takes a lot of computer memory...and is not efficient way.
Can anybody recommend me how to improve my code OR can anybody correct the above MouseListener. Thank You!