steverobinson

Sadaam |Drawing!

Jul 21st, 2011
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.geom.*;
  3. import javax.swing.*;
  4. public class Drawtest
  5. {
  6.     public static void main(String args[])
  7.     {
  8.         Drawframe frame=new Drawframe();
  9.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  10.         frame.setVisible(true);
  11.     }
  12. }
  13. class Drawframe extends JFrame
  14. {
  15.     public Drawframe()
  16.     {
  17.         setTitle("SADAAM");
  18.         setSize(400,400);
  19.         Drawpanel panel=new Drawpanel();
  20.         add(panel);
  21.     }
  22. }
  23. class Drawpanel extends JPanel
  24. {
  25.     public void paintComponent(Graphics g)
  26.     {
  27.         //super.paintComponent(g);
  28.         Graphics2D g2=(Graphics2D)g;
  29.         double leftx=100,topy=100;
  30.         double width=200,height=100;
  31.         Rectangle2D rect=new Rectangle2D.Double(leftx,topy,width,height);
  32.         Ellipse2D elp=new Ellipse2D.Double(leftx,topy,width,height);
  33.         Line2D lin=new Line2D.Double(leftx,topy,leftx+width,topy+height);
  34.         g2.draw(rect);
  35.         g2.draw(elp);
  36.         g2.draw(lin);
  37.     }
  38. }
Add Comment
Please, Sign In to add comment