About 8,640,000 results
Open links in new tab
  1. Draw a Polygon in Java Applet - GeeksforGeeks

    May 8, 2018 · We can draw Polygon in java applet by three ways : drawPolygon (int [] x, int [] y, int numberofpoints) : draws a polygon with the given set of x and y points. import javax.swing.*; drawPolygon (Polygon p) : draws a polygon with the given object of …

  2. Polygon (Java Platform SE 8 ) - Oracle

    The Polygon class encapsulates a description of a closed, two-dimensional region within a coordinate space. This region is bounded by an arbitrary number of line segments, each of which is one side of the polygon.

  3. How to Draw a Polygon in Java: A Step-by-Step Guide

    Drawing a polygon in Java can be efficiently done using the Abstract Window Toolkit (AWT) and Swing libraries. This process involves defining the vertices of the polygon, creating a graphical component, and then rendering it on the screen using the `paintComponent` method.

  4. swing - about drawing a Polygon in java - Stack Overflow

    Mar 3, 2013 · poly = new Polygon(xPoly, yPoly, xPoly.length); protected void paintComponent(Graphics g){ super.paintComponents(g); g.setColor(Color.BLUE); g.drawPolygon(poly); /** * @param args. */ public static void main(String[] args) { new jRisk(); JFrame does not have a paintComponent(Graphics g) method.

  5. graphics - How to fill a polygon in java? - Stack Overflow

    Feb 12, 2016 · arrayX(),//ArrayY() and arrayX() are methods that generate arrays with random numbers. arrayY(), MAX. )); Here is the View class: Map map=new Map(); super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; //....... g2.draw(map.area);//this draws the normal polygon NOT filled.

  6. How to draw a polygon using GUI in Java - Online Tutorials Library

    Following example demonstrates how to draw a polygon by creating Polygon () object. addPoint () & drawPolygon () method is used to draw the Polygon.

  7. JavaFX | Polygon with examples - GeeksforGeeks

    Oct 25, 2019 · Polygon class creates a polygon with the given set of x and y coordinates. Polygon class inherits the shape class. Constructors of the class are: Commonly used methods: Gets the coordinates of the Polygon vertices. Below programs will illustrate the Polygon class of JavaFX:

  8. java - How to create Graphics object for drawing Polygon

    Aug 5, 2013 · I need to draw a Polygon - by connecting consecutive points and then connecting the last point to the first. With this goal I tried to use drawPolygon(xPoints, yPoints, nPoints). To my mind it's ...

  9. Java: Polygons - cs.rutgers.edu

    Use the Graphics methods g.drawPolygon(p) or g.fillPolygon(p) to draw or fill a polygon, where p is the polygon. For example, super.paintComponent(g); // paint background. g.fillPolygon(myTri); // fills triangle above. One useful feature of Polygons is that it's easy to check if a point is inside or outside a polygon.

  10. How to Implement Polygon2D in Java 2D Graphics?

    In Java, the `Polygon` class from the `java.awt` package enables you to draw complex shapes. This guide will walk you through implementing a simple 2D polygon within a GUI application using Java Swing.

  11. Some results have been removed
Refresh