void (Graphics2D g2d, Color background, int x1, int y1) { Component view = getView(); if (background != null && view != null) { int x2 = x1, x3 = getWidth() - x2, x4 = x3; int y2 = y1, y3 = getHeight() - y2, y4 = y3; if (myInsets.left > 0 && view.getX() < 0) { x2 += myInsets.left; } if (myInsets.top > 0 && view.getY() < 0) { y2 += myInsets.top; } if (myInsets.right > 0 && view.getX() > getWidth() - view.getWidth()) { x3 -= myInsets.right; } if (myInsets.bottom > 0 && view.getY() > getHeight() - view.getHeight()) { y3 -= myInsets.bottom; } Component parent = myAlways ? null : getParent(); if (parent instanceof JScrollPane pane) { JScrollBar vBar = pane.getVerticalScrollBar(); if (vBar != null && vBar.isVisible()) { if (vBar.getX() < getX()) { x2 = x1; } else { x3 = x4; } } JScrollBar hBar = pane.getHorizontalScrollBar(); if (hBar != null && hBar.isVisible()) { if (hBar.getY() < getY()) { y2 = y1; } else { y3 = y4; } } } Color transparent = ColorUtil.toAlpha(background, 0); if (x1 != x2) { g2d.setPaint(new GradientPaint(x1, y1, background, x2, y1, transparent)); g2d.fillPolygon(new int[]{x1, x2, x2, x1}, new int[]{y1, y2, y3, y4}, 4); } if (x3 != x4) { g2d.setPaint(new GradientPaint(x3, y1, transparent, x4, y1, background)); g2d.fillPolygon(new int[]{x4, x3, x3, x4}, new int[]{y1, y2, y3, y4}, 4); } if (y1 != y2) { g2d.setPaint(new GradientPaint(x1, y1, background, x1, y2, transparent)); g2d.fillPolygon(new int[]{x1, x2, x3, x4}, new int[]{y1, y2, y2, y1}, 4); } if (y3 != y4) { g2d.setPaint(new GradientPaint(x1, y3, transparent, x1, y4, background)); g2d.fillPolygon(new int[]{x1, x2, x3, x4}, new int[]{y4, y3, y3, y4}, 4); } } }