void (Graphics g, JComponent c) { Alignment alignment = Alignment.get(c); if (alignment != null && g instanceof Graphics2D) { Color background = !isOpaque(c) ? null : c.getBackground(); if (background != null) { g.setColor(background); g.fillRect(0, 0, c.getWidth(), c.getHeight()); } Rectangle bounds = new Rectangle(c.getWidth(), c.getHeight()); JBInsets.removeFrom(bounds, c.getInsets()); // process an area before the track Component leading = ComponentUtil.getClientProperty(c, LEADING); if (leading != null) { if (alignment == Alignment.LEFT || alignment == Alignment.RIGHT) { int size = leading.getPreferredSize().height; leading.setBounds(bounds.x, bounds.y, bounds.width, size); bounds.height -= size; bounds.y += size; } else { int size = leading.getPreferredSize().width; leading.setBounds(bounds.x, bounds.y, size, bounds.height); bounds.width -= size; bounds.x += size; } } // process an area after the track Component trailing = ComponentUtil.getClientProperty(c, TRAILING); if (trailing != null) { if (alignment == Alignment.LEFT || alignment == Alignment.RIGHT) { int size = trailing.getPreferredSize().height; bounds.height -= size; trailing.setBounds(bounds.x, bounds.y + bounds.height, bounds.width, size); } else { int size = trailing.getPreferredSize().width; bounds.width -= size; trailing.setBounds(bounds.x + bounds.width, bounds.y, size, bounds.height); } } // do not set track size bigger that expected thickness if (alignment == Alignment.LEFT || alignment == Alignment.RIGHT) { int offset = bounds.width - getThickness(); if (offset > 0) { bounds.width -= offset; if (alignment == Alignment.RIGHT) bounds.x += offset; } } else { int offset = bounds.height - getThickness(); if (offset > 0) { bounds.height -= offset; if (alignment == Alignment.BOTTOM) bounds.y += offset; } } boolean animate = !myTrack.bounds.equals(bounds); // animate thumb on resize if (animate) myTrack.bounds.setBounds(bounds); updateThumbBounds(animate); paintTrack((Graphics2D)g, c); // process additional drawing on the track RegionPainter<Object> track = ComponentUtil.getClientProperty(c, JBScrollBar.TRACK); if (track != null && myTrack.bounds.width > 0 && myTrack.bounds.height > 0) { track.paint((Graphics2D)g, myTrack.bounds.x, myTrack.bounds.y, myTrack.bounds.width, myTrack.bounds.height, null); } // process drawing the thumb if (myThumb.bounds.width > 0 && myThumb.bounds.height > 0) { paintThumb((Graphics2D)g, c); } } }