Java Swing Tutorial - Java Color.getRGB()








Syntax

Color.getRGB() has the following syntax.

public int getRGB()

Example

In the following code shows how to use Color.getRGB() method.

import java.awt.Color;
/* w ww .  j a v a 2s  . c o m*/
public class Main {
  public static void main(String[] args) {
    Color myColor = Color.RED;          

    System.out.println(myColor.getRGB());
    
  }
}

The code above generates the following result.