Joel
Joel

Reputation: 30156

Prevent table cell losing focus when underlying row model is updated

I have an editable JTable. If a user is editing a cell when the underlying row model is updated the cell editor loses focus.

What's the simplest solution to this?

Upvotes: 1

Views: 351

Answers (1)

Boro
Boro

Reputation: 7943

The simplest solution to this, as @mKorbel noticed, very theoretical question :) is to:

  1. Always remember which cell has the focus.
  2. Listen to row changes.
  3. When the underlying row is changed at the end of the method, called after the change is done, give back the focus to the right cell, e.g. using requestFocus(), example available here.

Upvotes: 3

Related Questions