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 to find a factorial of a given number

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

  3. Program to show an example of using a Non-Static Nested Class

  4. Program to show the use of Bitwise Operator (~) Complement

  5. Biological Sequence Allignment Using Dynamic Programing

  6. Program to show an example of getting at characters in a String

  7. Program to read input from the Standard Input Device

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

  9. An applet of displaying simple moving banner

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

  11. Program that accepts a shopping list of five items from the command line and stores them in vector

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

  13. Program to show an example of Copying i.e. Clonning Objects

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

  15. CORBA program for displaying the date and time of the server machine, client machine and the difference between these two date and time

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

  17. Program to show an example of using Abstract Class and Abstract Method

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

  19. Program that will count the number of lines in each file that is specified on the command line

  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 An applet program to draw Polygon Graph with given data