On Tue, 6 Jun 2023 22:55:06 GMT, Harshitha Onkar <[email protected]> wrote:

>> test/jdk/java/awt/Mixing/AWT_Mixing/ViewportOverlapping.java line 164:
>> 
>>> 162:         OverlappingTestBase.doMain(args);
>>> 163:         captureScreen("Img_5.png");
>>> 164:     }
>> 
>> It is just a test, so no need to over-engineer it but  it 'feels wrong' to 
>> specify the file name
>> as foo.png here and separately inside captureScreen choose 'png' as the file 
>> type to use.
>> Perhaps  captureScreen("Img_5.png", "png")  ?
>
> Updated

It doesn't feel right this way either. A cleaner approach would be to pass the 
undecorated file name and add the extension and specify the format inside 
`captureScreen`. (Passing the same value as a parameter usually produces an IDE 
warning, which means the parameter is not necessary.)


captureScreen("Img_5");

ImageIO.write(
        robot.createScreenCapture(new Rectangle(0, 0, screenSize.width, 
screenSize.height)),
        "png",
        new File(filename + ".png")
);

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14289#discussion_r1221410051

Reply via email to