What exactly does getValueIsAdjusting do?
java, jtable, swing
Solution
As the javadoc which JB Nizet linked to states, `getValueIsAdjusting()` checks whether a specific event (a change) is part of a chain, if so it will return `true`. It will only return `false` when the specified event is the final one in the chain.
In your case, selecting a row by clicking actually fires two events: a `mouseDown` and `mouseUp` event and both are sent to your event listener. If you correctly implement `getValueIsAdjusting()` to return whenever the value is `true`, you will only act on the final event in the chain, which is the `mouseUp` event that fires when you let go of the left mouse button.
The Java Tutorials include an example that captures events, you can use that to log the selection events and experiment with it yourself. Remove the return on the `event.getValueIsAdjusting()` check to log every event that's fired.
Problem
As you know, without using `!getValueIsAdjusting` when you select a row in a jtable (by clicking) the selection change event fire twice. It doesn't happen if you select a row using the keyboard arrow. To resolve it, you check if `getValueIsAdjusting` returns false. My question is why does the event fire twice if I select a row by clicking it, but not when using the keyboard arrow? And what does getValueIsAdjusting do to resolve it?