Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4724980

JTable: Add API to control what happens to edits when table loses focus.

XMLWordPrintable

    • Fix Understood
    • generic
    • generic

      JTable needs API that will allow developers to specify what happens to an ongoing edit when JTable loses focus. There have been multiple bugs on this issue, occurring over a long period of time.

      Originally, the behavior was to do absolutely nothing when focus is lost. This was a bad idea since, upon focus lost, the visible JTable could be left out of sync with its model.

      Next, the behavior was to always cancel edits. This wasn't very well liked by users of JTable.

      A more recent approach to solve this problem was to take a "commit-or-cancel" approach. That is, attempt to commit any ongoing edit and only cancel it if that fails. This would satisfy most developer's needs, but could break backward compatibility for those that assumed no action is taken.

      As a result, the current behavior is to again do nothing, with the ability to turn on "commit-or-cancel" by putting a client property on JTable, like this:

      table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE)

      Still, we believe more needs to be done. Even the "commit-or-cancel" behavior is not flexible enough since it gives the developer no notification when their edit is cancelled. As a result, data could be lost.

      The purpose of this RFE is to request API that will make this behavior customizable, and a decent default implementation that will satisfy most developers.

            peterz Peter Zhelezniakov
            shickeysunw Shannon Hickey (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: