/*
Get Alpha Component Of Color Example
This java example shows how to get Alpha Component from Color
using Java AWT Color class.
*/
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
/*
<applet code="GetAlphaComponent" width=200 height=100>
</applet>
*/
public class GetAlphaComponent extends Applet{
public void paint(Graphics g){
//create a custom color using RGB
Color customColor = new Color(255,10,10);
/*
* To get Alpha component of Color, use
* int getAlpha() method of AWT Color class.
*/
int alpha = customColor.getAlpha();
g.drawString("Alpha component : " + alpha, 10,50);
}
}
Example Output

Bookmark/Search this post with: