Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java: How to draw Polyline and Polygone

Java: How to draw Polyline and Polygone
{filelink=9431}

   import java.awt.Graphics;
   import java.awt.Polygon;
   import javax.swing.*;
   public class GEOPoly extends JPanel
   {
    public void paintComponent( Graphics g )
    {
       super.paintComponent( g ); 
       // Draw a Polygone
       int xValues[] = { 20, 40, 50, 30, 20, 15 };
       int yValues[] = { 50, 50, 60, 80, 80, 60 };
       Polygon polygon1 = new Polygon( xValues, yValues, 6 );
       g.drawPolygon( polygon1 );                            
       // Draw a Polyline
       int xValues2[] = { 70, 90, 100, 80, 70, 65, 60 };
       int yValues2[] = { 100, 100, 110, 110, 130, 110, 90 };
       g.drawPolyline( xValues2, yValues2, 7 );              
    }
    	public static void main (String[] args)
    		{
    		 JFrame frame=new JFrame("Polygone And Polyline")	;
    		 JPanel policePanel=new GEOPoly();
    		 frame.add(policePanel);
    		 frame.setSize(300,200);
    		 frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
    		 frame.setVisible(true);
            }
 }

Users who found this page were searching for:

  • drawpolyline java
  • java polygon draw polyline
  • polyline javax.swing
  • java polygon and polyline
  • polyline java
  • java draw polyline example
  • java Polyline
  • how+to+draw+an+polyline+in+java+swing
  • draw polyline java
  • java polyline arrays example

No comments yet.

Leave a Comment