Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update a table cell on keypress

Status
Not open for further replies.

Trevor2008

Technical User
Feb 19, 2008
12
US
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:
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
					
				}});
		     
		    }
thank you in advance for helping
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top