<

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Java2D lucid glass look

Published on
5,914 Points
2,914 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
0 Comments

Featured Post

CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month