Trevor2008
Technical User
I am trying to update a table cell on key press.
I have a table that gets the selected row and column with focusGained()
but I am having trouble updating cell on key release with the key event/key released. The cell will update if it losses focus and I then return to it. Is there a way I can update the cell on key-release without overriding table model? if not can some one help with how to override table model so that on key-release will update the cell?
relevant code below:
thank you in advance for helping
I have a table that gets the selected row and column with focusGained()
but I am having trouble updating cell on key release with the key event/key released. The cell will update if it losses focus and I then return to it. Is there a way I can update the cell on key-release without overriding table model? if not can some one help with how to override table model so that on key-release will update the cell?
relevant code below:
Code:
table2.addFocusListener(new FocusListener(){
@Override
public void focusGained(FocusEvent arg0) {
// TODO Auto-generated method stub
System.out.println("your here");
}
@Override
public void focusLost(FocusEvent arg0) {
// TODO Auto-generated method stub
System.out.println("your a bitch");
}});
table2.addKeyListener(new KeyListener(){
@Override
public void keyPressed(KeyEvent arg0) {
// TODO Auto-generated method stub
System.out.println("some shit just happened"+ table2.getValueAt(table2.getSelectedRow(), table2.getSelectedColumn()));
}
@Override
public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void keyTyped(KeyEvent arg0) {
// TODO Auto-generated method stub
}});
}