Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to listen for cell selection changes within a JTable

splungebobJul 29 2011 — edited Jul 29 2011
Problem: my table has 8 columns, with 4 of them containing very large text (up to 1000 chars). Solution is to set the initial size these columns so that the 1st 20 chars are visible, and if one of these columns gains focus/selection via mouse-clicking/tabbing/arrow keys, the entire text is shown in a JTextArea below the table.

I added a ListSelectionListener to the table, but this only informs me when the row selection has changed.

I added a FocusListener to the table, but this only informs me when the table gains/loses focus, not when it's been changed within.

I added a TableColumnModelListener to the TableColumnModel, but this only informs me when the column selection has changed.

I didn't bother with MouseListener as this won't handle change of selection via tabbing.

The LSL got me half way there, and the TCML got me the other half. Any ideas on how to combine?

Or is there something obvious that I'm missing?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 26 2011
Added on Jul 29 2011
3 comments
285 views