Java2D lucid glass look

Published:
Updated:
For customizing the look of your lightweight component and making it look lucid like it was made of glass.

Or: how to make your component more Apple-ish ;)

This tip assumes your component to be of rectangular shape and completely opaque.
public void paint(Graphics2D g2d, Object arg1, int w, int h) {
                          // your graphic code here ...
                      
                          g2d.setPaint(
                              new GradientPaint(
                                  0, 0, new Color(255, 255, 255, 150), 0, h, new Color(0, 0, 0, 0)
                              )
                          );
                      
                          g2d.fillRect(0, 0, w, h/2);
                      }

Open in new window

0
3,255 Views

Comments (0)

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.