Java Color CodesJava programming language allows us to create different types of applications like windows application or web application. The user interface is an important factor while developing an application. The GUI of the Java application can be made interactive using different colors available in Java programming. Java Color ConstantsThe color constants in Java are values that cannot be changed and can be used with different Java programs. The following table shows the color constants available in the Java programming. The all-capital version depicts a constant value. But lowercase version also works fine.
Java Color CodesThe basic colors of color system are red, green, and blue. Java provides the Color class constructor with different RGB color codes as arguments. Many developer tools are available that helps in picking up the correct RGB value. The following table shows some color code combinations using different RGB values.
Java AWT Color Class ProgramJava Abstract Window Toolkit is an API for developing GUI based Java applications. Let's create a Java program and use the Color class. ColorExample.java Output: In the above code, an instance of a JPanel p is created. The Color class object c1 is created using the RGB values (0, 0, 204) passed as an argument to the constructor. The c1 color object is assigned as the background color for the JPanel p. Java Color Constants ProgramColorConstExample.java Output: Next TopicJDoodle Java |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India