Java AWT color example tutorial: This simple AWT program in java is used to display the string with colors. You can color your text by using this source code. An AWT tutorial is easy to understand. An example code is given below.
COLOR IN JAVA AWT
This Java AWT program will display the colors in a screen by using default RGB values and each and every color having alpha values. Finally alpha values will be calculated and tabulated in the color space.
[Useful: C Programming Guide] & [IT Companies List]
Color code in Java AWT:
Q: Write a program for displaying colored text using Java AWT class.
//Import statements import java.awt.*; //Class definition class Colors extends Frame { public Colors(String title) { super(title); addWindowListener(new MyWindowListener()); setBackground(Color.yellow); setSize(300,300); show(); } public void paint(Graphics g) { Font f=new Font("Times New Roman",Font.BOLD,30); g.setFont(f); //Color c=new Color(255,255,255); g.setColor(Color.red); g.drawString("STUDENTS3K – Karthikh Venkat",100,190); } // © http://students3k.com – Karthikh Vemkat public static void main(String args[]) { new Colors("Colors Demo"); } }