Advertisement
fromMars

Display Different Shapes

Apr 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. /**Following example demonstrates how to display different shapes using Arc2D, Ellipse2D, Rectangle2D, RoundRectangle2D classes.
  2. **/
  3. import java.awt.Shape;
  4. import java.awt.geom.*;
  5.  
  6. public class Main {
  7.    public static void main(String[] args) {
  8.       int x1 = 1, x2 = 2, w = 3, h = 4,
  9.       x = 5, y = 6,
  10.        y1 = 1, y2 = 2, start = 3;
  11.      
  12.       Shape line = new Line2D.Float(x1, y1, x2, y2);
  13.       Shape arc = new Arc2D.Float(x, y, w, h, start, 1, 1);
  14.       Shape oval = new Ellipse2D.Float(x, y, w, h);
  15.       Shape rectangle = new Rectangle2D.Float(x, y, w, h);
  16.       Shape roundRectangle = new RoundRectangle2D.Float (x, y, w, h, 1, 2);
  17.       System.out.println("Different shapes are created:");
  18.    }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement