Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.geom.*;
- import javax.swing.*;
- public class Drawtest
- {
- public static void main(String args[])
- {
- Drawframe frame=new Drawframe();
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setVisible(true);
- }
- }
- class Drawframe extends JFrame
- {
- public Drawframe()
- {
- setTitle("SADAAM");
- setSize(400,400);
- Drawpanel panel=new Drawpanel();
- add(panel);
- }
- }
- class Drawpanel extends JPanel
- {
- public void paintComponent(Graphics g)
- {
- //super.paintComponent(g);
- Graphics2D g2=(Graphics2D)g;
- double leftx=100,topy=100;
- double width=200,height=100;
- Rectangle2D rect=new Rectangle2D.Double(leftx,topy,width,height);
- Ellipse2D elp=new Ellipse2D.Double(leftx,topy,width,height);
- Line2D lin=new Line2D.Double(leftx,topy,leftx+width,topy+height);
- g2.draw(rect);
- g2.draw(elp);
- g2.draw(lin);
- }
- }
Add Comment
Please, Sign In to add comment