BCA

AJAVA LAB

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6

PART B

PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10 PROGRAM 11 PROGRAM 12 PROGRAM 13 PROGRAM 14 PROGRAM 15 . . .

Create a webpage using html to display college information with appropriate images and list of departments.

 

 
 
 
/*
1. Create a Frame inside an applet and rotate a shape inside the frame using java2D (Graphics2D
class)


Run similer to frames
javac Program1.java

java Program 
*/
import java.awt.*;
  import java.awt.event.*;
import java.applet.Applet;  
 import java.util.concurrent.TimeUnit;
  
 
   
public class Program1 extends java.applet.Applet    
{  
 private int width = 500;
    private int height = 500;
    
    private int x = width / 2;
    private int y = height / 2;
    
    private double direction=1;
    private double angle=5;
    
    
    private double vX;
    private double vY;

 int a =100, b=100;


         
   public void init()  
   {  
        
       
    }  

       
       public void paint(Graphics g)
         {
                // g.drawRect(50, 35, 150, 150); 

              g.setColor( Color.BLACK );
              g.fillRect( 0, 0, width, height );
              g.setColor( Color.WHITE );
              g.drawString(" The angle of Rotation: " + angle, 10, 10 );
            

            try{
             for (int i = 0; i<360; i++){
                TimeUnit.SECONDS.sleep(1);

             // angle=10;
            direction =  Math.PI / 360;
 
	        //vX = Math.cos( angle )*angle  ; 
                vX= a *Math. cos(  i)  ;


	        //vY = Math.sin( angle ) *angle ;
                vY = b * Math.sin(  i)   ;
               
                g.clearRect(1, 1,  width - 2,  height - 2);
                g.setColor( Color.BLACK );
                g.fillRect( 0, 0, width, height );
                g.setColor( Color.WHITE );

                g.drawString(" The angle of Rotation: " + angle+ " "+vX +" "+vY , 10, 10 );
            // g.drawOval(x ,y ,a,b);
               g.drawOval(x    +(int)vX, y +(int)vY ,  60, 100);
         
              }
          } catch(InterruptedException e) {}
         }  
 
   static Frame f;
  public static void main(String [] args)  
  {  
       f = new Frame("Applet c");  
       Applet ex = new Applet();  
        
 
       f .add(new Program1());

       //f.add("Center", ex);  
       f.pack();  
       f.show();  
       f.setSize(500,500);

         
  
   }  


 
	  

	 



   
}