< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java

Print this page

        

@@ -47,10 +47,12 @@
     private int progressPadding;
     private boolean rotateText; // added for Nimbus LAF
     private boolean paintOutsideClip;
     private boolean tileWhenIndeterminate; //whether to tile indeterminate painting
     private int tileWidth; //the width of each tile
+    private Dimension minBarSize; // minimal visible bar size
+    private int glowWidth; // Glow around the bar foreground
 
     /**
      * Creates a new UI object for the given component.
      *
      * @param x component to create UI object for

@@ -112,10 +114,12 @@
                 tileWidth *= 0.857;
             } else if ("mini".equals(scaleKey)){
                 tileWidth *= 0.784;
             }
         }
+        minBarSize = (Dimension)style.get(context, "ProgressBar.minBarSize");
+        glowWidth = style.getInt(context, "ProgressBar.glowWidth", 0);
         context.dispose();
     }
 
     /**
      * {@inheritDoc}

@@ -256,11 +260,11 @@
                             - (pBarInsets.top + progressPadding
                              + pBarInsets.bottom + progressPadding);
 
                     if (!SynthLookAndFeel.isLeftToRight(pBar)) {
                         x = pBar.getWidth() - pBarInsets.right - width
-                                - progressPadding;
+                                - progressPadding - glowWidth;
                     }
                 } else {  // JProgressBar.VERTICAL
                     x = pBarInsets.left + progressPadding;
                     width = pBar.getWidth()
                             - (pBarInsets.left + progressPadding

@@ -269,13 +273,13 @@
                             - (pBarInsets.top + progressPadding
                              + pBarInsets.bottom + progressPadding)));
                     y = pBar.getHeight() - pBarInsets.bottom - height
                             - progressPadding;
 
-                    // When the progress bar is vertical we always paint
-                    // from bottom to top, not matter what the component
-                    // orientation is.
+                    if (SynthLookAndFeel.isLeftToRight(pBar)) {
+                        y -= glowWidth;
+                    }
                 }
             }
         } else {
             boxRect = getBox(boxRect);
             x = boxRect.x + progressPadding;

@@ -305,13 +309,16 @@
                             context, g, x, i, width, tileWidth, pBar.getOrientation());
                 }
             }
             g.setClip(clip);
         } else {
+            if (minBarSize == null || (width >= minBarSize.width
+                    && height >= minBarSize.height)) {
             context.getPainter().paintProgressBarForeground(context, g,
                     x, y, width, height, pBar.getOrientation());
         }
+        }
 
         if (pBar.isStringPainted()) {
             paintText(context, g, pBar.getString());
         }
     }
< prev index next >