Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Use Alpha values to draw in Layers 
 

In this section, you will studied how to use alpha values to the draw the specific shape in layers.

 

Use Alpha values to draw in Layers

                         

In this section, you will studied how to use alpha values to the draw the specific shape in layers.

An alpha object produces the alpha value which changes with time specified by the parameters of the alpha object. The alpha value is the graphics state parameter that is used to composite objects to the existing page. At full intensity, objects are opaque. At zero intensity, objects are invisible. As the intensity decreases, the specific shape becomes transparent. It can be a part of vertex or texture. 
We are providing you an example which uses the alpha values to show transparency. A frame of size (350,300) is created. The g.fillOval() fills the oval shape with the color defined in the constructor new Color(150, 100, 100, 70) of class Color. The values defined in the constructor are alpha values which shows the transparency.

Here is the code of UseAlphaValues.java

import java.awt.*;
import javax.swing.*;

public class UseAlphaValues extends JFrame {
int width, height;

  UseAlphaValues(String st) {
    this(st, 350300);
  }
  UseAlphaValues(String st, int w, int h) {
    setTitle(st);
    setSize(width = w, height = h); 
    setBackground(Color.black);
    }
   public void paint(Graphics g) {
    Color color1 = new Color(15010010070); 
    Color color2 = new Color(75150200125);
    Color color3 = new Color(120150200200);
    g.setColor(color1);
    g.fillOval(00, width / 2, height / 2);
    g.setColor(color2);
    g.fillOval(width / 4, height / 4, width / 2, height / 2);
    g.setColor(color3);
    g.fillOval(width / 3, height / 3, width / 4, height / 4);
  }
  public static void main(String[] args) {
    new UseAlphaValues("Use Alpha values to draw in layers.")
      .setVisible(
true);
  }
}

Output will be displayed as:

Download Source Code

                         

» View all related tutorials
Related Tags: c string class text mono rendering method 2d get type font display return context int ai render center define if

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.