The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.awt  [78 examples] > Drawing  [7 examples]

e576. Drawing with Alpha

    // See e575 The Quintessential Drawing Program
    public void paint(Graphics g) {
        Graphics2D g2d = (Graphics2D)g;
    
        // Draw background...
    
        // Set alpha.  0.0f is 100% transparent and 1.0f is 100% opaque.
        float alpha = .3f;
        g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
    
        // Draw foreground...
    }

 Related Examples
e575. The Quintessential Drawing Program
e577. Enabling Antialiasing
e578. Setting the Clipping Area with a Shape
e579. Changing the Thickness of the Stroking Pen
e580. Stroking or Filling with a Texture
e581. Animating an Array of Images in an Application

See also: Colors    Components    Containers    Cursors    Events    Focus    Frames    GridBagLayout    Images    Shapes    Simulating Events    Text    The Screen   


© 2002 Addison-Wesley.