Dimension (JComponent c) { int thickness = getThickness(); Alignment alignment = Alignment.get(c); Dimension preferred = new Dimension(thickness, thickness); if (alignment == Alignment.LEFT || alignment == Alignment.RIGHT) { preferred.height += preferred.height; addPreferredHeight(preferred, ComponentUtil.getClientProperty(myScrollBar, LEADING)); addPreferredHeight(preferred, ComponentUtil.getClientProperty(myScrollBar, TRAILING)); } else { preferred.width += preferred.width; addPreferredWidth(preferred, ComponentUtil.getClientProperty(myScrollBar, LEADING)); addPreferredWidth(preferred, ComponentUtil.getClientProperty(myScrollBar, TRAILING)); } return preferred; }