Skip to content

Commit 978b65f

Browse files
hansonrhansonr
authored andcommitted
fix for button vertical alignment -- should use fm.ascent()
1 parent 407f485 commit 978b65f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,13 +2402,14 @@ protected void setAlignments(AbstractButton b, boolean justGetPreferred) {
24022402
return;
24032403
}
24042404
preferredDim = null;
2405-
2405+
// fix for button vertical alignment -- should offset just by the ascent
2406+
String yoff = (wIcon == 0 ? "-" + (jc.getFont().getFontMetrics().getAscent()>>1) + "px" : "-50%");
24062407
DOMNode.setStyles(centeringNode, "position", "absolute", "top", null, "left", null, "transform", null);
24072408
if (alignHCenter && alignVCenter && wIcon == 0
24082409
|| wText == 0 && margins.left == margins.right && margins.top == margins.bottom) {
24092410
// simple totally centered label or button
24102411
DOMNode.setStyles(centeringNode, "top", "50%", "left", "50%", "transform",
2411-
"translateX(-50%)translateY(-50%)");
2412+
"translateX(-50%)translateY("+ yoff + ")");
24122413
return;
24132414
}
24142415

0 commit comments

Comments
 (0)