Skip to content

Commit

Permalink
Merge pull request #5424 from jmacxx/cashbymail_enhance_terms2
Browse files Browse the repository at this point in the history
Size popup proportional to amount of text shown
  • Loading branch information
ripcurlx committed Apr 21, 2021
2 parents e7446b0 + ca98975 commit 57adbdc
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ private void addContent() {
textArea.setEditable(false);
textArea.setWrapText(true);
// sizes the textArea to fit within its parent container
textArea.setPrefSize(Layout.INITIAL_WINDOW_WIDTH, Layout.INITIAL_WINDOW_HEIGHT * 0.9);
double verticalSizePercentage = ensureRange(countLines(message) / 20.0, 0.2, 0.7);
textArea.setPrefSize(Layout.INITIAL_WINDOW_WIDTH, Layout.INITIAL_WINDOW_HEIGHT * verticalSizePercentage);
}

private static int countLines(String str) {
String[] lines = str.split("\r\n|\r|\n");
return lines.length;
}

private static double ensureRange(double value, double min, double max) {
return Math.min(Math.max(value, min), max);
}
}

0 comments on commit 57adbdc

Please sign in to comment.