Creates a new color with the same color components but a different alpha value. - Java Swing

Java examples for Swing:JComponent

Description

Creates a new color with the same color components but a different alpha value.

Demo Code


//package com.java2s;
import java.awt.Color;

public class Main {
    /**/*from  w w w . j a  v  a  2  s.  co m*/
     * Creates a new color with the same color components but a different
     * alpha value.
     *
     * @param color Original color.
     * @param alpha Alpha value for new color.
     * @return New color with specified alpha value.
     */
    public static Color deriveWithAlpha(Color color, int alpha) {
        return new Color(color.getRed(), color.getGreen(), color.getBlue(),
                alpha);
    }
}

Related Tutorials