Tuesday, 14 November 2017

java ghraphig print 3d cone



This is main class
package test;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.ColorModel;
import javax.swing.JFrame;
class Test
{
   public static void main(String args[])
         
   {  String title="ALLAH IS ONE";
       for(int i=0;i<3;i++){
       JFrame f= new JFrame();
       f.setSize(200,300);
       if(i==2)
       f.setTitle(title);
       paint P= new paint();
       f.add(P);
       f.setVisible(true);
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 }
 }}
After the main class create a new class of paint and call it in main class
  

package test;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.Ellipse2D;

public class paint extends JComponent {
    public void paint(Graphics g)
    {
        Graphics2D g2 = (Graphics2D) g;
        g2.drawString("An intelligent face", 10, 10);
      
   int i=70,j=99,k=200,l=249;
   for(int h=0;h<100;h++)
   {
    Ellipse2D.Double E3= new Ellipse2D.Double(i,j,k,l);  
      g2.draw(E3);
      i-=1;
      j+=1;
      k-=4;
      l-=7;
   
   }
  g2.setColor(Color.LIGHT_GRAY);

    }
   
}
 

Output is 
                  




No comments:

Post a Comment