Skip to content

Commit a88e79c

Browse files
hansonrhansonr
authored andcommitted
label centering broken
1 parent cd67c87 commit a88e79c

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,11 +2179,8 @@ protected void setHorizontalButtonAlignments(AbstractButton b, int hTextPos, int
21792179
// DOMNode.setAttr(textNode, "innerHTML", pos);
21802180

21812181

2182-
int wIcon = (iconNode == null ? 0 : imageNode == null ? 20 : Math.max(0, setHTMLSize1(iconNode, false, false).width - 1));
2183-
if (isMenuItem && actionNode != null)
2184-
wIcon = 15;
2185-
int wText = setHTMLSize1(textNode, false, false).width - 1;
2186-
2182+
int wIcon = (actionNode != null ? (isMenuItem ? 15 : 20) : iconNode == null ? 0 : imageNode == null ? 0 : Math.max(0, setHTMLSize1(iconNode, false, false).width - 1));
2183+
int wText = setHTMLSize1(textNode, false, false).width - 1;
21872184
int gap = (wText == 0 || wIcon == 0 ? 0 : b.getIconTextGap());
21882185

21892186
// But we need to slightly underestimate it so that the
@@ -2261,7 +2258,7 @@ protected void setHorizontalButtonAlignments(AbstractButton b, int hTextPos, int
22612258
DOMNode.setStyles(domNode, "text-align", alignlr, poslr, px0);
22622259
//}
22632260
if (centered) {
2264-
int w = setHTMLSize1((buttonNode == null ? domNode : centeringNode), false, false).width;
2261+
int w = cellComponent != null ? cellWidth : setHTMLSize1((buttonNode == null ? domNode : centeringNode), false, false).width;
22652262
switch (hTextPos) {
22662263
case SwingConstants.CENTER:
22672264
case SwingConstants.TOP:

0 commit comments

Comments
 (0)