On Tue, 1 Mar 2022 23:27:57 GMT, DamonGuy <d...@openjdk.java.net> wrote:
>> 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. > > DamonGuy has updated the pull request incrementally with one additional > commit since the last revision: > > Updated test to be headless using BufferedImage. Changes requested by aivanov (Reviewer). test/jdk/javax/swing/JButton/HtmlButtonImageTest/HtmlButtonImageTest.java line 42: > 40: import java.io.IOException; > 41: import java.io.File; > 42: import javax.imageio.ImageIO; Could you sort the imports, please? *Optimize Imports* or a similar command in your IDE should do the magic. test/jdk/javax/swing/JButton/HtmlButtonImageTest/HtmlButtonImageTest.java line 68: > 66: > 67: SwingUtilities.invokeAndWait(HtmlButtonImageTest::createButton); > 68: SwingUtilities.invokeAndWait(HtmlButtonImageTest::createImage); `paintButton` would be clearer. test/jdk/javax/swing/JButton/HtmlButtonImageTest/HtmlButtonImageTest.java line 100: > 98: } > 99: > 100: private static boolean checkRedness(int rgb) { `checkRed` or `checkRedColor`? test/jdk/javax/swing/JButton/HtmlButtonImageTest/HtmlButtonImageTest.java line 114: > 112: System.out.println("Passed"); > 113: } > 114: } It's usually recommended to end the file with a new line. ------------- PR: https://git.openjdk.java.net/jdk/pull/7310