RFR: JDK-8015739: Background of JInternalFrame is located out of JInternalFrame [v7]

Alexey Ivanov aivanov at openjdk.org
Wed Oct 5 17:06:25 UTC 2022


On Tue, 4 Oct 2022 22:06:07 GMT, Harshitha Onkar <honkar at openjdk.org> wrote:

>> JInternalFrame background color seems to overflow into the border region. This issue is more prominently seen on Windows - Metal LAF (with fractional scaling, as shown below). The primary reason is border scaling issue as observed in - [JDK-8279614](https://bugs.openjdk.org/browse/JDK-8279614) 
>> 
>> The fix involves a similar approach as described here https://github.com/openjdk/jdk/pull/7449#issuecomment-1068218648. The test checks the midpoint and corners of borders to check if the internal frame's background color is located out of JInternalFrame.
>> 
>> ![image](https://user-images.githubusercontent.com/95945681/190233555-a7e00f2c-9003-4c11-84fb-207957838c2f.png)
>
> Harshitha Onkar has updated the pull request incrementally with one additional commit since the last revision:
> 
>   review changes

Other that a couple of nits, it looks good to me.

src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java line 254:

> 252:          *
> 253:          * @param d number to be rounded
> 254:          * @return a {@code int} which is the rounded value of provided number

Suggestion:

         * Rounds a double to the nearest integer. It rounds 0.5 down,
         * for example 1.5 is rounded to 1.0.
         *
         * @param d number to be rounded
         * @return the rounded value

src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java line 257:

> 255:          */
> 256:         private static int roundHalfDown(double d)
> 257:         {

Suggestion:

        private static int roundHalfDown(double d) {

test/jdk/javax/swing/JInternalFrame/InternalFrameBorderTest.java line 42:

> 40: import javax.swing.SwingUtilities;
> 41: import javax.swing.UIManager;
> 42: import javax.imageio.ImageIO;

`ImageIO` shouldn't have moved.

test/jdk/javax/swing/JInternalFrame/InternalFrameBorderTest.java line 81:

> 79:     private static final int BORDER_THICKNESS = 5;
> 80: 
> 81:     private static StringBuffer errorLog = new StringBuffer();

Suggestion:

    private static final StringBuffer errorLog = new StringBuffer();

IDE issues a warning that `errorLog` can be final and it should.

test/jdk/javax/swing/JInternalFrame/InternalFrameBorderTest.java line 89:

> 87: 
> 88:     private static Point iFrameLoc;
> 89:     private static int iFrameMaxX;

I think `jFrameBounds` logically belongs in this block.

test/jdk/javax/swing/JInternalFrame/InternalFrameBorderTest.java line 105:

> 103:             robot = new Robot();
> 104:             robot.setAutoDelay(200);
> 105:             uiScale =System.getProperty("sun.java2d.uiScale");

Suggestion:

            uiScale = System.getProperty("sun.java2d.uiScale");

A space is missing.

test/jdk/javax/swing/JInternalFrame/InternalFrameBorderTest.java line 178:

> 176:                 || borderDirection.equals("LEFT");
> 177:         boolean isHorizontal =  borderDirection.equals("TOP")
> 178:                 || borderDirection.equals("BOTTOM");

Suggestion:

        boolean isVertical = borderDirection.equals("RIGHT")
                || borderDirection.equals("LEFT");
        boolean isHorizontal = borderDirection.equals("TOP")
                || borderDirection.equals("BOTTOM");

No need for additional space after `=` sign.

test/jdk/javax/swing/JInternalFrame/InternalFrameBorderTest.java line 222:

> 220:             createMRIScreenCapture(cornerLocation + "_uiScale"
> 221:                     + uiScale + ".png");
> 222:             errorLog.append("At uiScale: "+ uiScale + ", Red background color"

Suggestion:

            errorLog.append("At uiScale: " + uiScale + ", Red background color"

A space before `+`.

test/jdk/javax/swing/JInternalFrame/InternalFrameBorderTest.java line 255:

> 253:         try {
> 254:             ImageIO.write(image,
> 255:                     "png", new File(filename));

Wrapping is redundant now.

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

Marked as reviewed by aivanov (Reviewer).

PR: https://git.openjdk.org/jdk/pull/10274



More information about the client-libs-dev mailing list