On Thu, 6 Nov 2025 07:37:49 GMT, Prasanta Sadhukhan <[email protected]> 
wrote:

> Test is made headless

Changes requested by aivanov (Reviewer).

test/jdk/javax/swing/text/GlyphView/TestGlyphBGHeight.java line 52:

> 50:     static int getEmptyPixel() {
> 51:         return 0xFFFFFFFF;
> 52:     }

Do you need a method? Can't it be a constant?


    private static final Color EMPTY_PIXEL = new Color(0xFFFFFFFF);

test/jdk/javax/swing/text/GlyphView/TestGlyphBGHeight.java line 63:

> 61:                     g.fillRect(0, 0, WIDTH, HEIGHT);
> 62:                 }
> 63:             });

You can draw into the image on the thread where you created it.

test/jdk/javax/swing/text/GlyphView/TestGlyphBGHeight.java line 70:

> 68: 
> 69:         final BufferedImage img = createImage();
> 70:         SwingUtilities.invokeAndWait(() -> {

You can create the text component directly on the main thread. The component 
will never be accessed from EDT if you perform all the operations on the main 
thread.

test/jdk/javax/swing/text/GlyphView/TestGlyphBGHeight.java line 71:

> 69:         final BufferedImage img = createImage();
> 70:         SwingUtilities.invokeAndWait(() -> {
> 71:             final JTextPane comp = new JTextPane();

I'd rather name it `textPane`, it's more descriptive than `comp`.

test/jdk/javax/swing/text/GlyphView/TestGlyphBGHeight.java line 83:

> 81: 
> 82:             comp.setSize(WIDTH, HEIGHT);
> 83:             comp.setDocument(doc);

`setDocument` is a no-op and is not needed, you modified the document that's 
already installed into the component.

test/jdk/javax/swing/text/GlyphView/TestGlyphBGHeight.java line 93:

> 91:         BufferedImage bimg = img.getSubimage(0, FONTSIZE + 20, WIDTH, 1);
> 92:         ImageIO.write(bimg, "png", new File("AppTest1.png"));
> 93:         for (int x = 10; x < WIDTH/ 2; x++) {

Suggestion:

        for (int x = 10; x < WIDTH / 2; x++) {

test/jdk/javax/swing/text/GlyphView/TestGlyphBGHeight.java line 98:

> 96:             if (col.equals(Color.YELLOW)) {
> 97:                 throw new RuntimeException(" Background is painted taller 
> than needed for styled text");
> 98:             }

Suggestion:

            int col = bimg.getRGB(x, 0);
            System.out.println(Integer.toHexString(col));
            if (col != Color.YELLOW.getRGB()) {
                throw new RuntimeException("Background is painted taller than 
needed for styled text");
}

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

PR Review: https://git.openjdk.org/jdk/pull/28173#pullrequestreview-3429631823
PR Review Comment: https://git.openjdk.org/jdk/pull/28173#discussion_r2500117414
PR Review Comment: https://git.openjdk.org/jdk/pull/28173#discussion_r2500119803
PR Review Comment: https://git.openjdk.org/jdk/pull/28173#discussion_r2500145516
PR Review Comment: https://git.openjdk.org/jdk/pull/28173#discussion_r2500124142
PR Review Comment: https://git.openjdk.org/jdk/pull/28173#discussion_r2500158068
PR Review Comment: https://git.openjdk.org/jdk/pull/28173#discussion_r2500130800
PR Review Comment: https://git.openjdk.org/jdk/pull/28173#discussion_r2500139189

Reply via email to