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. Servlet which takes input from an HTML client page and calculates and outputs the premium amount

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

  3. Corba program of UDP client server application which sends the news to the client. Server takes the news from the NewsDataFile located at the server

  4. Program of reading and writing primitive data

  5. Program of storing and retrieving integers using data streams on a single file

  6. CORBA PROGRAM TO GET THE HTML CODE FROM ANY URL

  7. An applet program to perform selection sort

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

  9. Program to display Floyds Triangle of a numbers

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

  11. Program to read the price of an item in decimal form (like 75.95) and print the output in paise (like 7595 paise).

  12. Program to print some text on the same line using multiple print statements

  13. Program, which creates a three thread. One thread display the numbers from 1 to 5, second thread display the square root of that number etc

  14. Socket program of multi client chat server

  15. An applet program to display text

  16. Program to read rollno, marks of sub1,sub2 and sub3 and on basis of that display result

  17. Given a list of marks ranging form 0 to 100, write a program to compute and print the number of students marks

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

  19. Program that demonstrates type casting

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

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