Java Tutorial

 
 
 
 
/* <applet code=\"ColorBar\" height=400 width=400> 
    </applet>  */

import java.awt.*;
import java.applet.*;

public class ColorBar extends Applet
{
    Color colors[]={ Color.blue, Color.cyan, Color.yellow, Color.red, Color.darkGray,
                               Color.gray, Color.lightGray, Color.magenta, Color.orange, Color.pink,
                               Color.white, Color.black};

        public void paint(Graphics g){
             Dimension d = getSize();
             int x = d.height/colors.length;
             setBackground(Color.lightGray);
             for (int i=0; i<colors.length ; i++ )
             {
                   g.setColor(colors[i]);
                   g.fillRect(0, i*x , d.width, (i+1) * x);
             }
        }
}

    Related Post:
  1. Program to show the use of operator (&lt;&lt;) Shift Left filling with zero from the right

  2. An application that combines several classes and interface

  3. An applet program to add two numbers where data is entered in TextField

  4. Program to read bytes from a file

  5. program which takes a long sentence from the client passes to the server,server separates out each word and sends them back to client in reverse order

  6. Program of linear search

  7. Corba program to encrypt the text that you want to send on the client side. The server side decrypts it after receiving. Append server time.

  8. Program to sort the contents of an array using Bubble Sort

  9. Program to declare, initialize and print a String object

  10. Program to display Floyds Triangle of a numbers

  11. Program of concatenating and Buffering files

  12. Program which creates an Array of character. Make one function with one argument as a character and that function throw a user defined exception

  13. Program to show an example of extraction of characters from a StringBuffer objects

  14. Even no or Prime no?????

  15. Corba program to Write a Echo server and client with UDP server and client

  16. Program that takes a long sentence and a character from the client and count the occurrence of the character in the sentence at the server side

  17. File handling program to count number of characters in a file

  18. Program to show the use of While Loop

  19. An applet program showing Clicked Event on canvas

  20. CORBA program for displaying the date and time of the server machine, client machine and the difference between these two date and time

 
 
Didn't find what you were looking for? Find more on An applet program to display Horizontal Color Bar