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 that demonstrates type casting

  2. Program to read input from the Standard Input Device

  3. Program to determine the sum of the following harmonic series for a given value of n

  4. Program to show the use of Logical AND Operator (&) in If Statements

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

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

  7. Corba program of game

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

  9. Program to show the use of Bitwise Operator (&) AND

  10. Program to search an element in an array using Linear Search

  11. Do the following for the Array Insert the element in the array,delete an element from the array,search for a particular element Create multiple thread

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

  13. Program to show the use of Comparison operator (==) for comparing Strings

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

  15. Program to show an example of using a Static Nested Class

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

  17. Application for counting factorial of a given number

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

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

  20. Program of bubble sort

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