Java Applet ile yapılmış elips çevresinde dönen top

package applet;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JOptionPane;


public class elipscevresidonentop extends Applet implements MouseListener,Runnable {
    int sayac;
    double x,y;
  
  
    public void init(){
        Thread s=new Thread(this);
        setSize(800,800);
       
        x=375;
        y=300;
       
          addMouseListener(this);
          
        
          
           s.start();
    }
    public void paint(Graphics a){
        a.setColor(Color.DARK_GRAY);
        a.fillOval(300, 350, 200, 100);
        a.setColor(Color.CYAN);
        a.fillOval((int)x+375,(int)y+375 , 50, 50);
        a.setColor(Color.RED);
     
        a.fillOval(350,375 ,25,40 );
        a.fillOval(450, 375, 25, 40);
        
   
    }
    public void run(){
        try {
            
            while(true){
                Thread.sleep(10);
            x=125*Math.cos((Math.PI/180)*sayac);
            y=  75 *Math.sin((Math.PI/180)*sayac);
            sayac--;
            repaint();
            }   
        } catch (Exception e) {
        }
    }

   
  public void mousePressed(MouseEvent e)
  {
      switch (e.getButton()){
                case MouseEvent.BUTTON1:
                    System.exit(0);
                case MouseEvent.BUTTON2:
                    break;
                case MouseEvent.BUTTON3:
                    break;
                default:
                    break;}
  }

  
    public void mouseClicked(MouseEvent e) {
         
    }

 
    public void mouseReleased(MouseEvent e) {
   
    }

 
    public void mouseEntered(MouseEvent e) {
      
    }

   
    public void mouseExited(MouseEvent e) {
       
    }
}

Ekran Görüntüsü;

 

 

Yorumlar

Bu gönderi için yorum yapılmadı.