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 show some properties of StringBuffer object

  2. Corba program of game

  3. Program to show an example of Overriding a Base Class Method

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

  5. Program that enabled applet calculator

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

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

  8. An applet program that display blinking rectangle

  9. Develop a game application in CORBA for which the player will guess a number between 1 to 100, which will be compared to the random number generated b

  10. Program to show an example of extracting subStrings from a String

  11. Program to change characters in a StringBuffer objects and to reverse its contents

  12. Program to show the use of Logical or Boolean Negation i.e. NOT (!)

  13. Program to show an example of using a Static Nested Class outside the Top-Level Class

  14. Word list program that reads a text file and makes an alphabetical list of all the words in that file. The list of words is output to another file

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

  16. Program to perform Merge Sort

  17. Program to show an example of creating a class and using its object

  18. Program to display reverse $ tree

  19. Program to find a factorial of a given number

  20. Application which takes your marks of six subjects from the client side and displays the percentage that you have obtained

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