From 17f35ba1f3866a3dc40fa7dc24d39ba7387b7bcf Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier <goetz@openjdk.org> Date: Thu, 31 Oct 2024 09:45:17 +0000 Subject: [PATCH] 8340308: PassFailJFrame: Make rows default to number of lines in instructions Backport-of: d1d824008d1dc70029013820814fd03c40b4e309 --- .../awt/regtesthelpers/PassFailJFrame.java | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java b/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java index 51433faa303..e2693e7c555 100644 --- a/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java +++ b/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java @@ -1184,11 +1184,45 @@ public final class PassFailJFrame { return this; } + /** + * Sets the number of rows for displaying the instruction text. + * The default value is the number of lines in the text plus 1: + * {@code ((int) instructions.lines().count() + 1)}. + * + * @param rows the number of rows for instruction text + * @return this builder + */ public Builder rows(int rows) { this.rows = rows; return this; } + private int getDefaultRows() { + return (int) instructions.lines().count() + 1; + } + + /** + * Adds a certain number of rows for displaying the instruction text. + * + * @param rowsAdd the number of rows to add to the number of rows + * @return this builder + * @see #rows + */ + public Builder rowsAdd(int rowsAdd) { + if (rows == 0) { + rows = getDefaultRows(); + } + rows += rowsAdd; + + return this; + } + + /** + * Sets the number of columns for displaying the instruction text. + * + * @param columns the number of columns for instruction text + * @return this builder + */ public Builder columns(int columns) { this.columns = columns; return this; @@ -1483,7 +1517,7 @@ public final class PassFailJFrame { } if (rows == 0) { - rows = ROWS; + rows = getDefaultRows(); } if (columns == 0) { -- GitLab