@@ -747,7 +747,6 @@ protected void ignoreAllMouseEvents(DOMNode node) {
747747
748748 @ SuppressWarnings ("unused" )
749749 protected static void hideAllMenus () {
750- //System.out.println("JSCUI hideAllMenus" + JSUtil.getStackTrace(-3));
751750 JSUtil .jQuery .$ (".ui-j2smenu" ).hide ();
752751 if (/** @j2sNative javax.swing.ToolTipManager ||*/ false )
753752 ToolTipManager .j2sHideToolTip ();
@@ -1542,8 +1541,6 @@ protected Dimension setHTMLSize1(DOMNode node, boolean addCSS, boolean usePrefer
15421541 $ (body ).after (div );
15431542 Rectangle r = div .getBoundingClientRect ();
15441543
1545- //System.out.println("JSCUI " + (int) (r.width + 0.) + " " + (/** @j2sNative div.innerHTML ||*/""));
1546-
15471544 // From the DOM; Will be Rectangle2D.double, actually.
15481545 // This is preferable to $(text).width() because that is rounded
15491546 // DOWN.
@@ -1556,9 +1553,6 @@ protected Dimension setHTMLSize1(DOMNode node, boolean addCSS, boolean usePrefer
15561553 actualWidth = w ;
15571554 actualHeight = h ;
15581555 }
1559- // h = preferredHeight;// (iconHeight > 0 ? iconHeight :
1560- // centerHeight);
1561- // TODO what if centerHeight is > prefHeight?
15621556 $ (div ).detach ();
15631557 }
15641558 // allow a UI to slightly adjust its dimension
@@ -2307,7 +2301,7 @@ protected void setAlignments(AbstractButton b, boolean justGetPreferred) {
23072301 int gap = (wText == 0 || wIcon == 0 ? 0 : b .getIconTextGap ());
23082302 int w = cellComponent != null ? cellWidth : $ (domNode ).width ();
23092303 boolean alignVCenter = (vAlign == SwingConstants .CENTER );
2310- Insets margins = (isLabel ? insets : b .getMargin ());
2304+ Insets margins = (isAWT ? b . getInsets () : isLabel ? insets : b .getMargin ());
23112305 if (margins == null )
23122306 margins = zeroInsets ;
23132307 int h = (dimText == null ? 0 : dimText .height );
@@ -2416,7 +2410,7 @@ protected void setAlignments(AbstractButton b, boolean justGetPreferred) {
24162410 }
24172411 preferredDim = null ;
24182412 // fix for button vertical alignment -- should offset just by the ascent
2419- String yoff = ( wIcon == 0 ? "-" + ( jc . getFont (). getFontMetrics (). getAscent ()>> 1 ) + "px" : "- 50%") ;
2413+ String yoff = "- 50%" ;
24202414 DOMNode .setStyles (centeringNode , "position" , "absolute" , "top" , null , "left" , null , "transform" , null );
24212415 if (alignHCenter && alignVCenter && wIcon == 0
24222416 || wText == 0 && margins .left == margins .right && margins .top == margins .bottom ) {
@@ -2514,6 +2508,7 @@ protected void setAlignments(AbstractButton b, boolean justGetPreferred) {
25142508 switch (vTextPos ) {
25152509 case SwingConstants .TOP :
25162510 top = itop = 0 ;
2511+ yoff = null ;
25172512 break ;
25182513 default :
25192514 case SwingConstants .CENTER :
@@ -2522,12 +2517,14 @@ protected void setAlignments(AbstractButton b, boolean justGetPreferred) {
25222517 itop = 70 ;
25232518 iscale = "scale(0.6,0.6)" ;
25242519 }
2520+ yoff = (wIcon == 0 ? "-" + ((jc .getFont ().getFontMetrics ().getAscent ()>>1 )+1 ) + "px" : "-50%" );
25252521 break ;
25262522 case SwingConstants .BOTTOM :
25272523 top = itop = 100 ;
2524+ yoff = null ;
25282525 break ;
25292526 }
2530- DOMNode .setStyles (textNode , "top" , top + "%" , "transform" , "translateY(-" + top + "%)" );
2527+ DOMNode .setStyles (textNode , "top" , top + "%" , "transform" , "translateY(" + ( yoff == null ? " -" + top + "%" : yoff + ")" ) );
25312528 DOMNode .setStyles (iconNode , "top" , top + "%" , "transform" ,
25322529 "translateY(-" + itop + "%)" + (iscale == null ? "" : iscale ));
25332530 } else {
0 commit comments