RFR: 8015854: [macosx] JButton's HTML ImageView adding unwanted padding

DamonGuy duke at openjdk.java.net
Wed Feb 2 21:53:46 UTC 2022


Html does not fit in JButton at certain sizes because default Insets cause html to be displayed off-center. 

Changes made to SwingUtilities.java layoutCompoundLabelImpl method to enable clipping if html does not fit, similar to regular text. AquaButtonUI.java now detects when html does not fit, and an implementation for alternate insets that are recursively tested for regular text inside layoutAndGetText() are now also being used for html content.

Created test (Bug8015854.java) with the same format as the test described on the issue. The button is of size 37x37 with an image of a red square sized 19x19. The test checks for red pixels on the edges of where the square image should be from the center of the button. The test fails with the non-changed jdk, but passes with the changes.

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

Commit messages:
 - Adjusted pixel buffer variable to also be public to match other final variables.
 - Updated test to include copyright and moved the jtreg tags to the top.
 - Changed pixels checked to one from edge of red square to avoid checking antialiased pixels and added buffer for slight offsets due to different resolutions.
 - Changed pixels checked to one from edge of red square to avoid checking antialiased pixels.
 - Added jtreg test for HtmlButtonPadding issue
 - Added logic to handle html clipping to fix AquaButtonUI JButton padding issue

Changes: https://git.openjdk.java.net/jdk/pull/7310/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=7310&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8015854
  Stats: 145 lines in 3 files changed: 143 ins; 0 del; 2 mod
  Patch: https://git.openjdk.java.net/jdk/pull/7310.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/7310/head:pull/7310

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



More information about the client-libs-dev mailing list