In this section, you will study about the alpha-values and alpha-rules.
To give blending and transparency effects with graphics and images and the alpha values, the class AlphaComposite is used. An alpha value of 0.0f makes the source disappear and 1.0f make it completely opaque. Various degrees of translucency exist between the 0.0f and 1.0f. We are providing you an example.
We have defined two ComboBox for alpha-values and alpha-rules respectively. We have given five alpha-values i.e. 0.0, 0.25, 0.50, 0.75, 1.0. The existing image is called destination and the image rendered on it is the source.
ItemEvent.SELECTED is the state-change value which indicates that an item was selected. The getSelectedItem() returns the selected item. To show different alpha-values and alpha-rules, the class Ellipse2D defines two ovals which act as a source and destination. In the given example, cyan colored oval act as a destination and red colored oval act as a source.
Here is the code of CompositeExample.java
import java.awt.*;
|
Output will be displayed as:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Show Alpha Value and Alpha Rules
Post your Comment