Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Tabbing between cells in a JTable

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to create a JTable that acts like a set of JTextFields, with the top row and left column rendered as JLabels. The code below works fine, but I'd like to be able to tab between cells and the cell to immediately go into edit mode (so it's invisible to the user that this is actually a table). Additionally I'd like it to skip uneditable cells, so tabbing on a far right cell doesn't move to the label on the next row, but to the next editable cell. I've spent quite a while trying to figure this one out but with no luck, so does anyone have any pointers?

If you run the code below you will see that clicking in an editable cell automatically puts it into edit mode (with cursor and changed text position) but tabbing doesn't give any visual indications, though if you start typing it starts editing.

Thanks for any help, and here;s the code:

 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd like to be able to tab between cells and the cell to immediately go into edit mode
(so it's invisible to the user that this is actually a table). Additionally I'd like it to
skip uneditable cells, so tabbing on a far right cell doesn't move to the label on the
next row, but to the next editable cell.

I got your code to work (as described above) with only the following additions:
 
Jonathan Moore
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's great - thanks for your help Craig.

Jon
 
I brought this back from the farm where they grow the tiny ads:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic