RFR: 8190264: JScrollBar ignores its border when using macOS Mac OS X Aqua look and feel [v4]
Alexey Ivanov
aivanov at openjdk.java.net
Mon Dec 6 23:26:14 UTC 2021
On Mon, 6 Dec 2021 23:01:05 GMT, Alisen Chung <achung at openjdk.org> wrote:
>>> In the TestBadBreak example, how do you know it's properly painting onto the final BufferedImage? When I try the same it doesn't seem to be painting anything on the BufferedImage, so there's no colors to compare.
>>
>> How do you paint the frame into BufferedImage?
>> You may need to set the size of the frame explicitly.
>>
>> There are many tests which paint components to the image. You can also take a look at test/jdk/javax/swing/text/FlowView/6318524/bug6318524.java and test/jdk/javax/swing/text/ParagraphView/6364882/bug6364882.java. Each of these two provides an option to save the BufferedImage to a file.
>
>> How do you paint the frame into BufferedImage?
> You may need to set the size of the frame explicitly.
>
> I'm overriding the paintComponent method of JPanel to instead directly paint onto a BufferedImage that I passed in, similar to the TestBadBreak example.
>
> I pushed what I have so far, but it seems like the BufferedImage is blank
The image is blank because this method is never called. `TestBadBreak` relies on the frame being shown, it adds the component into the frame and shows the frame to capture what's painted. You don't add the `panel` into the frame, therefore it's never painted.
Try to paint into the image directly, after you configured the panel, that is after `panel.add(scrollBar);`, call:
Graphics2D graphics2D = image.createGraphics();
panel.paint(graphics2D);
graphics2D.dispose();
Then you can analyse the colour of pixels on the image just like you do now with robot.
-------------
PR: https://git.openjdk.java.net/jdk/pull/6374
More information about the client-libs-dev
mailing list