<

Java2D lucid glass look

Published on
5,903 Points
2,903 Views
Last Modified:
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
Comment
0 Comments

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Join & Write a Comment

Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month