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

Java: Modify the characteristics of a shape using ‘Strok’ class

Java: Modify the characteristics of a shape using 'Strok' class
{filelink=9435}

 import java.awt.*;
 import java.awt.geom.*;
 import javax.swing.*;
/*
 * This example draws a
 * square and modifies its features
 */
 public class TraitCarre extends JFrame {
     public<span id="more-250"></span> TraitCarre()
     {
        setTitle("Java Stroke");
        setSize(200, 200);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
     }
     public static void main(String[] args)
     	 {
              new TraitCarre();
         }
   public void paint(Graphics g)
   	{
   	  Graphics2D g2 = (Graphics2D)g;
      Rectangle2D r = new Rectangle2D.Double(50, 50, 100, 100);
      Stroke stroke = new BasicStroke(8,BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0,
      new float[] { 12, 12 }, 0);
      g2.setStroke(stroke);
      g2.draw(r);
   }
}

Users who found this page were searching for:

  • graphics2d python
  • strok java
  • java stroke.setsize

No comments yet.

Leave a Comment