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. Corba program of Count Client Applet, IDL,Server, Client

  2. An applet program to display alternate filled and empty circle that to in row and column format

  3. Program to show an example of using multiple classes in a program

  4. Program of an applet to illustrate BarChart

  5. Program to show an example of Copying i.e. Clonning Objects

  6. Develop a simple calculator with addition, subtraction, multiplication and division capabilities, data collection from client side, executed on server

  7. Program that enabled applet calculator

  8. Program to compute the sum of the digits of a given integer number. eg: I/o=4 then O/p=4+3+2+1=10

  9. Program that reads and writes random access file

  10. Develop a RMI based application for addition of two complex numbers

  11. An applet program showing Clicked Event on canvas

  12. RMI based application for login validation based on data saved in text file stored on the server and will display appropriate message to the client..

  13. Program in CORBA which takes a long sentence from client (at least 7 words), passes to the server, server separates out each word and sends back

  14. Servlet which takes input from an HTML client page and calculates and outputs the premium amount

  15. Program to perform Merge Sort

  16. Program to show an example of Concatination of Strings

  17. Program to declare, initialize and print an array of integers

  18. File handling program to copy bytes from one file to another

  19. Program to append a StringBuffer by StringBuffer, String objects and other Basic Data Types

  20. Program to show the use of Nested If-Else Statements

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