<

Java2D opaque plastic look

Published on
5,732 Points
2,732 Views
Last Modified:
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  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);
}

Open in new window

0
Ask questions about what you read
If you have a question about something within an article, you can receive help directly from the article author. Experts Exchange article authors are available to answer questions and further the discussion.
Get 7 days free