Skip to content

Commit 750d713

Browse files
hansonrhansonr
authored andcommitted
JTextArea better row height calculation for preferred size
1 parent 0b7213f commit 750d713

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sources/net.sf.j2s.java.core/src/javax/swing/JTextArea.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ public void setRows(int rows) {
563563
protected int getRowHeight() {
564564
if (rowHeight == 0) {
565565
FontMetrics metrics = getFontMetrics(getFont());
566-
rowHeight = metrics.getHeight();
566+
rowHeight = metrics.getHeight() + 2; // SwingJS adds +2 here
567567
}
568568
return rowHeight;
569569
}
@@ -643,7 +643,7 @@ public Dimension getSizeJS(Dimension d, int n, int rows, int columns) {
643643
}
644644
if (rows != 0) {
645645
Insets insets = getInsets();
646-
d.height = Math.max(h, rows * getRowHeight() + insets.top + insets.bottom);
646+
d.height = Math.max(h, (rows + 1) * getRowHeight() + insets.top + insets.bottom);
647647
}
648648
return d;
649649
}

0 commit comments

Comments
 (0)