RFR: JDK-8282772: JButton text set as HTML content has unwanted padding [v2]

DamonGuy duke at openjdk.java.net
Wed Apr 27 18:52:46 UTC 2022


On Tue, 26 Apr 2022 20:15:20 GMT, Phil Race <prr at openjdk.org> wrote:

>> DamonGuy has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Changed approach to fix.
>
> src/java.desktop/share/classes/javax/swing/plaf/nimbus/skin.laf line 271:
> 
>> (failed to retrieve contents of file, check the PR for context)
>> I also tested for non-HTML text after the changes, and the changes do not affect normal text.
> 
> And this is true for this Nimbus case too ? Whereas your code update in BasicButtonUI is checking for HTML, I don't see how it could *not* change normal text in the Nimbus case.

I thought the same thing. In the test, I forced the L&F to nimbus only and tested with the left and right insets set to 0 and 14. The text appears normally and identically for both cases  (HTML text and non-HTML text). I also tried changing the size of the button from 37x37 to 100x100 and 200x200. The appearance was the same for all cases.

However, I just tried using different text from the tests before and I do get cases where text gets snipped to "..." when the new insets wouldn't. So, you're right that normal text is affected. I just used text that wasn't long enough in testing.

The reason I went this route for the fix was because in NimbusStyle, the insets are retrieved but the property key but the button component for BasicHTML is not set yet and returns null. So, I can't use this method to set the insets to 0 since the property key has not been set in the stack yet.

I finally found the applicable class of where to make the edits yesterday. I just made the changes similar to the other L&Fs.

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

PR: https://git.openjdk.java.net/jdk/pull/8407



More information about the client-libs-dev mailing list