Java – JTable – press tab to put the cell into edit mode

There may be a trivial solution, but I'm already at the end of my tether, so I hope someone can help

I use a JTable with a set of custom renderers and a set of custom editors The renderer uses jlabel components and the editor uses jspinner components Our users want to be able to enter values in the column and press tab or enter to move to the next editable cell in the table If I understand correctly, this is the default behavior of JTable

But it doesn't seem to work for me Jlabel is not displayed until the user clicks on the cell Jspinner (cell editor) is displayed only when the user double clicks a cell So it looks like the cell enters "Edit" mode only in mouseevents, but not when it has focus

Once there is focus, how can I put the cell into edit mode?

Solution

You can implement it programmatically. You just need to listen to the focus event on the cell, focus and edit, and start editing

More about this thread and example

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>