How to Get Alpha from Color in Java


This example will explain how to get Alpha component from color with AWT Color class in Java.

Source Code

package com.beginner.examples;

import java.awt.Color;

public class GetColorAlphaExample {

	public static void main(String[] args)
	{
		Color color = Color.green;
		
		int alpha = color.getAlpha();
		
		System.out.println("Alpha:"+alpha);
		
	}
	
}

Output:

255

References

Imported packages in Java documentation:

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments