protected void layoutVScrollbar(JScrollBar sb) { if (AbstractLookAndFeel.getTheme().isLinuxStyleScrollBarOn()) { Dimension sbSize = sb.getSize(); Insets sbInsets = sb.getInsets(); int sizeH = sbSize.height - sbInsets.top - sbInsets.bottom; /* * Width and left edge of the buttons and thumb. */ int itemX = sbInsets.left; int itemW = sbSize.width - (sbInsets.left + sbInsets.right); int itemH = Math.min(itemW, sizeH / 2); /* Nominal locations of the buttons, assuming their preferred * size will fit. */ int decrButtonY = sbSize.height - sbInsets.bottom - itemH - itemH + 1; int incrButtonY = sbSize.height - sbInsets.bottom - itemH; /* Compute the height and origin of the thumb. The case * where the thumb is at the bottom edge is handled specially * to avoid numerical problems in computing thumbY. Enforce * the thumbs min/max dimensions. If the thumb doesn't * fit in the track (trackH) we'll hide it later. */ float trackH = sbSize.height - sbInsets.top - sbInsets.bottom - itemW - itemW + 1; float min = sb.getMinimum(); float max = sb.getMaximum(); float extent = sb.getVisibleAmount(); float range = max - min; float value = sb.getValue(); int maxThumbH = getMaximumThumbSize().height; int minThumbH = getMinimumThumbSize().height; int thumbH = (range <= 0) ? maxThumbH : (int) (trackH * (extent / range)); thumbH = Math.max(thumbH, minThumbH); thumbH = Math.min(thumbH, maxThumbH); int thumbY = decrButtonY - thumbH; if (value < (max - extent)) { float thumbRange = trackH - thumbH; thumbY = (int) (0.5f + (thumbRange * ((value - min) / (range - extent)))); } /* If the thumb isn't going to fit, zero it's bounds. Otherwise * make sure it fits between the buttons. Note that setting the * thumbs bounds will cause a repaint. */ if (thumbH > trackH) { setThumbBounds(0, 0, 0, 0); } else { setThumbBounds(itemX, thumbY, itemW, thumbH); } decrButton.setBounds(itemX, decrButtonY, itemW, itemH); incrButton.setBounds(itemX, incrButtonY, itemW, itemH); /* Update the trackRect field. */ trackRect.setBounds(itemX, 0, itemW, (int) trackH); } else { super.layoutVScrollbar(sb); } }
protected void layoutVScrollbar(JScrollBar sb) { if (useAlternateLayout) alternateLayoutVScrollbar(sb); else super.layoutVScrollbar(sb); }