void (Graphics g, int p0, int p1, Shape shape, JTextComponent component) { Color color = component.getBackground(); if (color != null) { g.setColor(color); Rectangle bounds = shape instanceof Rectangle ? (Rectangle)shape : shape.getBounds(); g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); } }