1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
/* 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
Add Comment