RFR: 8341982: Simplify JButton/bug4323121.java [v4]
Alexey Ivanov
aivanov at openjdk.org
Mon Oct 21 14:38:33 UTC 2024
On Fri, 18 Oct 2024 19:16:14 GMT, Harshitha Onkar <honkar at openjdk.org> wrote:
>> Alexey Ivanov has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Remove space before comma
>>
>> Co-authored-by: Abhishek Kumar <abhishek.cx.kumar at oracle.com>
>
> test/jdk/javax/swing/JButton/bug4323121.java line 123:
>
>> 121: }
>> 122:
>> 123: private static final class TestButton extends JButton {
>
> There isn't much custom code within TestButton but it is retained as subclass of JButton because of test requirement?
The bug description for [JDK-4323121](https://bugs.openjdk.org/browse/JDK-4323121) mentions a subclass of `JButton`.
However, regular `JButton` also reproduces the bug, I verified that the test fails in 1.3.0 if I use `JButton` directly. The fix for JDK-4323121 is outlined in the comments. The fix modified the common handler for mouse events, before the fix the model had been armed in `mouseEntered`; after the fix the model is armed only if `model.isPressed` returns true.
https://github.com/openjdk/jdk/blob/330f2b5a9cad02b8e6882fc6eee996d7792d3de1/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicButtonListener.java#L290-L291
So, the test can be simplified further by using `JButton` instead of a subclass.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21475#discussion_r1808951326
More information about the client-libs-dev
mailing list