Java Tutorial

 
 
 
 
/*  Write a program to draw Polygon Graph with given data  */

/* <applet code=\"polyGraph\" height=400 width=500>  
   </applet>  */

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

public class polyGraph extends Applet
{
       public void paint(Graphics g){
           Dimension d = getSize();
           int canvasheight = d.height;

           int x[] = {0,60,120,180,240,300,360,420};
           int y[] = {0,120,180,260,340,340,300,180};

           //In order to converting java coordinate system to 
           //normal coordinate system, we transform the Y values
           //to N - Y where N is the height of the display area (canvas).

           for (int i=0;i<y.length ;i++ )
           {
                   y[i] = canvasheight - y[i];
           }

           int totPoints = x.length;   //To find total points in Array

           g.drawPolygon(x,y,totPoints);

      }
}

    Related Post:
  1. Program of bubble sort

  2. Develop a CORBA based application for addition of two complex numbers and displaying the result on client side

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

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

  5. Socket program of HTTP Server

  6. Program which creates an Array of character. Make one function with one argument as a character and that function throw a user defined exception

  7. An applet program to draw different shapes

  8. Program to declare and initialize Boolean variables and print them on the Standard Output Device

  9. An applet program to perform selection sort

  10. An applet program to draw concentric circle in center of the canvas

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

  12. Program to show an example of using user-defined package in a program

  13. Program to show the use of Switch Statement for the same statement for several different case labels

  14. Simple Applet which will show life cycle of an Applet

  15. CORBA based application for addition of two mathematical expressions of the form (ax + by) and displaying the result on client side

  16. Program to show the use of Conditional AND Operator (&&) in If Statements

  17. Program that enabled applet that takes name of the user. Server returns back the number in uppercase clubbed with “HELLO” and display it on applet

  18. Program to copy the elements of an array into another array in reverse order and print them

  19. Program to show an example of using a recursive method in a class

  20. Write a class whose objects holds a current value and have a method to add that value, printing the new value

 
 
Didn't find what you were looking for? Find more on An applet program to draw Polygon Graph with given data