Dimension (JComponent c) { Dimension size = super.getPreferredSize(c); if (!(c instanceof JProgressBar)) { return size; } if (!((JProgressBar)c).isStringPainted()) { if (((JProgressBar)c).getOrientation() == SwingConstants.HORIZONTAL) { size.height = getStripeWidth(); } else { size.width = getStripeWidth(); } } return size; }