RFR: 8310054: ScrollPane insets are incorrect

Alexey Ivanov aivanov at openjdk.org
Wed Jun 14 20:26:07 UTC 2023


After the size of `ScrollPane` child component changes, it recalculates the size of the scroll bars and hides or shows them as necessary. This situation is handled in `WScrollPanePeer.childResized`:

https://github.com/openjdk/jdk/blob/ee4ab6709ebaf8a1b1e9f297a7c53205987f3eba/src/java.desktop/windows/classes/sun/awt/windows/WScrollPanePeer.java#L104-L109

After [JDK-8297923](https://bugs.openjdk.org/browse/JDK-8297923), `setSpans` is run asynchronously on the toolkit thread. Thus, `setInsets` calculates the incorrect values because `setSpans` hasn't updated the sizes yet.

This is a regression from [JDK-8297923](https://bugs.openjdk.org/browse/JDK-8297923).

**Fix**

The insets are updated in the native implementation of `setSpans` directly.

The native implmenation of `setInsets` method is run on the toolkit thread as a synchronous call because the insets are used in [`WScrollPanePeer.initialize`](https://github.com/openjdk/jdk/blob/ee4ab6709ebaf8a1b1e9f297a7c53205987f3eba/src/java.desktop/windows/classes/sun/awt/windows/WScrollPanePeer.java#L62-L67).

-------------

Commit messages:
 - 8297923: Add the bugid to the test
 - 8310054: ScrollPane insets are incorrect

Changes: https://git.openjdk.org/jdk/pull/14478/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14478&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8310054
  Stats: 13 lines in 3 files changed: 7 ins; 1 del; 5 mod
  Patch: https://git.openjdk.org/jdk/pull/14478.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14478/head:pull/14478

PR: https://git.openjdk.org/jdk/pull/14478



More information about the client-libs-dev mailing list