• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java JTable keybindings working differently for tab and enter keys  RSS feed

 
Jaga Subbu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following requirement:
1. When tab/enter key is pressed in JTable, read the value in selected cell and go to the next cell
2. This should happen whether the cell is in select mode or edit mode

The program written is not working when a cell with existing value is edited by pressing F2 key and enter key is pressed. For all other scenarios it is working fine.
To recreate the issue, please follow the below steps:
         Enter "a" in cell(0,0) --> press enter key --> use left arrow to go to cell(0,0) --> press F2 key --> Enter "b" in cell(0,0) --> Press enter key --> Here action performed is not called.

Please review the below program and let me know what changes to be done to meet the requirement.

TableTest.java:

 
Tony Docherty
Bartender
Posts: 3271
82
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure if this is the ideal solution or what side effects may occur but you could reassign the F2 key to the same action as Enter ie add the following:

 
Tony Docherty
Bartender
Posts: 3271
82
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And Welcome to the Ranch
 
Jaga Subbu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the warm welcome...
I ll try it and let you if it works.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!