void () { int centerSpacing; // used to center sliders added using BorderLayout.CENTER (bug 4275631) if (slider.getOrientation() == SwingConstants.HORIZONTAL) { centerSpacing = thumbRect.height; if (slider.getPaintLabels()) centerSpacing += getHeightOfTallestLabel(); trackRect.setBounds(contentRect.x + trackBuffer, contentRect.y + (contentRect.height - centerSpacing) / 2, contentRect.width - (trackBuffer * 2), thumbRect.height); } else { centerSpacing = thumbRect.width; int offset = JBUIScale.scale(6); if (slider.getComponentOrientation().isLeftToRight()) { if (slider.getPaintLabels()) { centerSpacing += getWidthOfWidestLabel(); offset = -offset; } } else { if (slider.getPaintLabels()) { centerSpacing -= getWidthOfWidestLabel(); } } trackRect.setBounds(contentRect.x + (contentRect.width - centerSpacing) / 2 + offset, contentRect.y + trackBuffer, thumbRect.width, contentRect.height - (trackBuffer * 2)); } }