300301302303304305306307308309310
// Get a graphics context for this image Graphics2D g2 = mGhostImage.createGraphics(); // Ask the cell renderer to paint itself into the BufferedImage lbl2.paint(g2); // Use DST_OVER to cause under-painting to occur g2.setComposite(AlphaComposite.getInstance(AlphaComposite.DST_OVER, 0.5f));
22272228222922302231223222332234223522362237
// Ask the cell renderer to paint itself into the BufferedImage g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, 0.5f)); // Make // the // image // ghostlike lbl.paint(g2); // Now paint a gradient UNDER the ghosted JLabel text (but not under the // icon if any) // Note: this will need tweaking if your icon is not positioned to the // left of the text
330331332333334335336337338339340
g2.dispose(); } } g.translate(labelX, labelY); label.setSize(labelW, labelH); label.paint(g); g.translate(-labelX, -labelY); } else if (border != null) { border.paintBorder(c, g, x, y, width, height); }
99100101102103104105106107108109
g2d.drawImage(img, 0, 0, null); g2d.translate(0, imgtext.getHeight() - label.getHeight()); g2d.setPaint(gpaint); g2d.fillRect(0 , 0, imgtext.getWidth(), label.getHeight()); label.paint(g2d); g2d.dispose(); return imgtext; }
329330331332333334335336337338339
354355356357358359360361362363364
// Make the image ghostlike g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, 0.5f)); // Ask the cell renderer to paint itself into the BufferedImage rendererComponent.paint(g2d); // Finished with the graphics context now g2d.dispose(); }