@@ -2290,6 +2290,11 @@ protected int getDefaultIconTextGap() {
22902290
22912291 protected Dimension preferredDim ;
22922292
2293+ /**
2294+ * particularly for buttons
2295+ */
2296+ private boolean isFullyCentered ;
2297+
22932298 protected static Insets zeroInsets = new Insets (0 , 0 , 0 , 0 );
22942299
22952300 protected void getJSInsets () {
@@ -2358,19 +2363,18 @@ protected void setAlignments(AbstractButton b, boolean justGetPreferred) {
23582363 int wText = (dimText == null ? 0 : dimText .width );
23592364 int gap = (wText == 0 || wIcon == 0 ? 0 : b .getIconTextGap ());
23602365 int w0 = cellComponent != null ? cellWidth : $ (domNode ).width ();
2361- int w = w0 ;
2362- if (w < wIcon + wText ) {
2363- // jQuery method can fail that may not have worked.
2364- w = wIcon + wText ;
2366+ int w = w0 ;
2367+ if (w < wIcon + wText ) {
2368+ // jQuery method can fail that may not have worked.
2369+ w = wIcon + wText ;
23652370 }
23662371 boolean alignVCenter = (vAlign == SwingConstants .CENTER );
2367- Insets margins = (isLabel ? (isAWT ? b .getInsets () : insets ) :
2368- getButtonMargins (b , justGetPreferred ));
2372+ Insets margins = (isLabel ? (isAWT ? b .getInsets () : insets ) : getButtonMargins (b , justGetPreferred ));
23692373 if (margins == null )
23702374 margins = zeroInsets ;
2371- Insets insets = (isLabel || !isSimpleButton || justGetPreferred ? zeroInsets :
2372- getButtonOuterInsets ( b ));
2373- //System.out.println("JSCUI margins " + justGetPreferred + " " + b.getText() + " " + margins + " " + insets);
2375+ Insets insets = (isLabel || !isSimpleButton || justGetPreferred ? zeroInsets : getButtonOuterInsets ( b ));
2376+ // System.out.println("JSCUI margins " + justGetPreferred + " " + b.getText() +
2377+ // " " + margins + " " + insets);
23742378 int h = (dimText == null ? 0 : dimText .height );
23752379 int ih = (dimIcon == null ? 0 : dimIcon .height );
23762380 int hCtr = Math .max (h , ih );
@@ -2469,7 +2473,7 @@ protected void setAlignments(AbstractButton b, boolean justGetPreferred) {
24692473 w = w0 ;
24702474 break ;
24712475 }
2472- }
2476+ }
24732477 if (justGetPreferred ) {
24742478 if (preferredDim == null )
24752479 preferredDim = new Dimension ();
@@ -2481,17 +2485,19 @@ protected void setAlignments(AbstractButton b, boolean justGetPreferred) {
24812485 DOMNode .setStyles (centeringNode , "position" , "absolute" , "top" , null , "left" , null , "transform" , null );
24822486 DOMNode .setStyles (centeringNode , "width" , wCtr + "px" , "height" , hCtr + "px" );
24832487
2484- if (alignHCenter && alignVCenter && wIcon == 0
2485- || wText == 0 && margins .left == margins .right && margins .top == margins .bottom
2486- && insets .left == insets .right && insets .top == insets .bottom ) {
2488+ if (alignHCenter && alignVCenter && wIcon == 0 || wText == 0 && margins .left == margins .right
2489+ && margins .top == margins .bottom && insets .left == insets .right && insets .top == insets .bottom ) {
24872490
2488- // simple totally centered label or button
2489- // can't have width or height here --- let the browser figure that out
2490- fullyCenter (centeringNode , true );
2491- fullyCenter (iconNode , false );
2492- fullyCenter (textNode , false );
2491+ isFullyCentered = !isLabel ;
2492+ if (isFullyCentered ) {
2493+ // simple totally centered label or button
2494+ // can't have width or height here --- let the browser figure that out
2495+ fullyCenter (centeringNode , true );
2496+ fullyCenter (iconNode , false );
2497+ fullyCenter (textNode , false );
2498+ }
24932499 } else {
2494-
2500+ isFullyCentered = false ;
24952501 DOMNode .setStyles (iconNode , "position" , "absolute" , "top" , null , "left" , null , "transform" , null );
24962502 DOMNode .setStyles (textNode , "position" , "absolute" , "top" , null , "left" , null , "transform" , null );
24972503
@@ -2595,7 +2601,7 @@ protected void setAlignments(AbstractButton b, boolean justGetPreferred) {
25952601 yoff = "-50%" ;
25962602 break ;
25972603 }
2598- DOMNode .setStyles (centeringNode , "overflow" ,"none" );
2604+ DOMNode .setStyles (centeringNode , "overflow" , "none" );
25992605 DOMNode .setStyles (textNode , "top" , top + "%" , "transform" ,
26002606 "translateY(" + (yoff == null ? "-" + top + "%" : yoff + ")" ));
26012607 DOMNode .setStyles (iconNode , "top" , top + "%" , "transform" ,
0 commit comments