Wednesday, 15 November 2017

java very beautiful drawing

This is main class


package graphs;
import javax.swing.*;
public class Graphs {

   
    public static void main(String[] args) {
       String title="ALLAH IS ONE";
      
       JFrame f= new JFrame();
       f.setSize(700,700);
       f.setTitle(title);
       paints P= new paints();
       f.add(P);
       f.setVisible(true);
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    }
   
}

After writing main class create a class of paints and call it in main class

 

package graphs;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;

public class paints extends JComponent {
      public void paint(Graphics g)
    {
                Graphics2D g2 = (Graphics2D) g;
       
           int a=1,s=1,d=1,f=1,l=1,h=1,j=1,k=1;
           for(int z=0;z<100;z++) {
              Ellipse2D.Double R11= new Ellipse2D.Double(a,s,d,f);
           g2.draw(R11);
           g2.setColor(Color.yellow);
           g2.fill(R11);
 Ellipse2D.Double R12= new Ellipse2D.Double(h,j,k,l);
           g2.draw(R12);
           g2.setColor(Color.white);
           g2.fill(R12);
         a+=3;s+=3;d+=3;f+=3;h+=1;j+=1;k+=1;l+=1;
                    
          
    }
           a=200;s=200;d=200;f=200;l=200;h=200;j=200;k=200;
           for(int z=0;z<100;z++) {
              Ellipse2D.Double R11= new Ellipse2D.Double(a,s,d,f);
           g2.draw(R11);
           g2.setColor(Color.MAGENTA);
           g2.fill(R11);
 Ellipse2D.Double R12= new Ellipse2D.Double(h,j,k,l);
           g2.draw(R12);
           g2.setColor(Color.white);
           g2.fill(R12);
         a+=3;s+=3;d-=3;f-=3;h-=1;j-=1;k-=1;l-=1;
                    
          
    }}
}

Output is 

               

No comments:

Post a Comment