On Thu, 19 Jun 2025 09:47:28 GMT, Alexey Ivanov <[email protected]> wrote:
>> Compilation error on windows with `WindowsButtonUI` used. Replaced it with
>> `BasicButtonUI` to maintain overriding the `paintText` method but this was
>> not the same as Windows L&F buttons. I attempted to import `WindowsButtonUI`
>> and extending it, but the class is `final`. Instead, I chose to add a
>> LineBorder in the same way as when a Rectangle was drawn to keep the same
>> test behavior. It seems the extra 1 pixel width is unnecessary now when
>> testing, so the changes only include removing `MyButtonUI` and adding a
>> LineBorder.
>>
>> This updated test now compiles and runs as expected. The test has all of the
>> text within the blue button border. There does not seem to be any
>> overlapping or out of bounds text as originally described with the original
>> test.
>
> test/jdk/javax/swing/plaf/windows/bug4991587.java line 83:
>
>> 81: }
>> 82:
>> 83: static class MyButtonUI extends WindowsButtonUI {
>
> Use composition here: extend `BasicButtonUI`, create a `WindowsButtonUI`¹
> object and forward *all the methods*² to the instance of `WindowsButtonUI`.
> In the `paintText` method, draw the rectangle and then call the
> implementation of your `WindowsButtonUI`.
>
> ¹ Use `WindowsButtonUI.createUI` to create an instance.
> ² All the overridden methods in `WindowsButtonUI`.
It would be good if we could eliminate the reference to WindowsButtonUI. It
might also be useful to check the behavior across all L&Fs.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25883#discussion_r2156645107