void (Graphics g) { Rectangle bounds = new Rectangle(getWidth(), getHeight()); JBInsets.removeFrom(bounds, getInsets()); if (bounds.isEmpty()) return; if (myBackground != null) { if (myImage == null) myImage = ImageUtil.filter(myBackground, myFilter); } else if (myImage == null || bounds.width != myImage.getWidth(this) || bounds.height != myImage.getHeight(this)) { int[] array = new int[bounds.width * bounds.height]; float width = (float)(bounds.width - 1); float height = (float)(bounds.height - 1); for (int i = 0, h = 0; h < bounds.height; h++) { for (int w = 0; w < bounds.width; w++, i++) { float level = 2 * h / height; float saturation = (level > 1f) ? 1 : level; float brightness = (level > 1f) ? 2 - level : 1; array[i] = Color.HSBtoRGB(w / width, saturation, brightness); } } BufferedImage image = ImageUtil.createImage(g, bounds.width, bounds.height, BufferedImage.TYPE_INT_RGB); image.setRGB(0, 0, bounds.width, bounds.height, array, 0, bounds.width); myImage = ImageUtil.filter(image, myFilter); } g.drawImage(myImage, bounds.x, bounds.y, bounds.width, bounds.height, this); }