Java Swing Tutorial - Java Color .getColorComponents (float[] compArray)








Syntax

Color.getColorComponents(float[] compArray) has the following syntax.

public float[] getColorComponents(float[] compArray)

Example

In the following code shows how to use Color.getColorComponents(float[] compArray) method.

import java.awt.Color;
import java.util.Arrays;
// w  ww .java2  s . c  o m
public class Main {
  public static void main(String[] args) {

    Color myColor = Color.RED;          

    System.out.println(Arrays.toString(myColor.getColorComponents(null)));
    
  }
}

The code above generates the following result.