Java Tutorial

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

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

public class BarChart extends Applet
{
       TextField t1,t2,t3;
       public void init(){
             t1 = new TextField(8);
             t2 = new TextField(8);
             t3 = new TextField(8);
             add(t1);
             add(t2);
             add(t3);
             t1.setText(\"0\");
             t2.setText(\"0\");
             t3.setText(\"0\");
        }

        public void paint(Graphics g){
             try{
             g.drawString(\"Enter value in TextField to generate Barchart 

\",10,50);
             int value[] = new int[2];
             g.setColor(Color.red);
              value[0]= Integer.parseInt(t1.getText());
              value[1]=Integer.parseInt(t2.getText());
              value[2]=Integer.parseInt(t3.getText());

             for (int i=0;i<3;i++ )
             {
                    g.fillRect(100,i*50+70,value[i],40);
            }
            }catch(Exception e) {}
         }


      public boolean action(Event e, Object o){
          repaint();
          return true;
        }

}

    Related Post:
  1. Program to make directory

  2. File handling program to copy characters from one file to another

  3. 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

  4. Program to show an example of searching Strings for subStrings

  5. RMI application for getting the final total price of the shopping list with some of the following items and quantities chosen by the user

  6. Program to show the use of operator (&gt;&gt;&gt;) Shift Right, filling with zeros from the left

  7. Program to show an example of Concatination of Strings

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

  9. Program to show the use of Do-While Loop

  10. 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.

  11. Program to show the use of Labeled Continue Statement

  12. An applet program that creates string dynamically and displays it

  13. Program to show an example of creating a String object from a StringBuffer Object

  14. Biological Sequence Allignment Using Dynamic Programing

  15. Program to show an example of creating Character Arrays from String objects

  16. Program for Thread Priority

  17. An applet program that concatenates two string entered in TextField

  18. Program to show an example of using initialization block to initialize the data members of a class

  19. Pass the marks of 10 students from the client side design a servlet, which takes these marks and returns the number of students who obtained first cls

  20. 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

 
 
Didn't find what you were looking for? Find more on Program of an applet to illustrate BarChart