RFR: 8279614: The left line of the TitledBorder is not painted on 150 scale factor [v7]

Alexey Ivanov aivanov at openjdk.java.net
Mon Mar 28 16:19:51 UTC 2022


On Wed, 23 Mar 2022 18:24:05 GMT, Alisen Chung <achung at openjdk.org> wrote:

>> Changed the drawing area to be increased by 0.5 on the left side to prevent clipping
>
> Alisen Chung has updated the pull request incrementally with one additional commit since the last revision:
> 
>   scale stroke width at higher scalings

Changes requested by aivanov (Reviewer).

src/java.desktop/share/classes/javax/swing/border/EtchedBorder.java line 175:

> 173:                                                     : getShadowColor(c), w, h, stkWidth);
> 174:         paintBorderRect(g, (etchType == LOWERED) ? getShadowColor(c)
> 175:                                                     : getHighlightColor(c), w, h, stkWidth);

Is it possible to paint the border with the rectangles like it was before?

We know that the lines were overdrawn because of the scale and this is what the fix tries to correct to make both shadow and highlight always visible and of the same thickness.

test/jdk/java/awt/TitledBorder/TitledBorderTest.java line 46:

> 44:  * @bug 8279614
> 45:  * @summary The left line of the TitledBorder is not painted on 150 scale factor
> 46:  * @requires (os.family == "windows")

The test is not Windows specific, is it? Yet Java supports fractional scales on Windows only at the moment, right?

I still think it makes sense to run the test on Linux and macOS for 100%, 200% and 300% which are supported.

test/jdk/java/awt/TitledBorder/TitledBorderTest.java line 53:

> 51:   public static JFrame frame;
> 52:   public static JPanel parentPanel;
> 53:   public static JPanel childPanel;

Please correct the indentation in the test: each level is indented by four spaces.

test/jdk/java/awt/TitledBorder/TitledBorderTest.java line 76:

> 74:     for (int i = 15; i < 25 && testFail == 0; i++) {
> 75:       for (int j = 80; j < 100; j++) {
> 76:         if (buff.getRGB(i, j) == -0x5F5F60) {

The colour should not be hardcoded.

I suggest verifying the border is drawn correctly: the shadow and highlight lines have the correct thickness. Not only left side of the border should be verified but top, right, and bottom sides too.

test/jdk/java/awt/TitledBorder/TitledBorderTest.java line 85:

> 83: 
> 84:     for (int i = 15; i < 25 && testFail == 1; i++) {
> 85:       for (int j = 150; j < 170; j++) {

The second pair of the for-loops is the same as the first one but the start coordinates for `y` are different. It should be a method which accepts start coordinates rather than four nearly identical for-loops.

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

PR: https://git.openjdk.java.net/jdk/pull/7449



More information about the client-libs-dev mailing list