Java Prac 28
Java Prac 28
Java Prac 28
28
Develop a basic program to demonstrate applet.
/* <applet code=saee_applet.class width=500 height=500></applet>*/
importjava.applet.*;
System.out.println("Applet Initialized...");
System.out.println("Applet Start...");
System.out.println("Applet Stop...");
System.out.println("Applet Destroyed...");
}
}
Output:
C:\jdk1.7.0_80\bin>javac saee_applet.java
C:\jdk1.7.0_80\bin>appletviewer saee_applet.java
Applet Initialized...
Applet Start...
Applet Stop...
Applet Start...
Applet Stop...
Applet Destroyed...
Develop a basic applet to display “Welcome to the world of
Applet”.
/* <applet code=saee_applet1.class width=500 height=500></applet>*/
importjava.applet.*;
importjava.awt.*;
g.drawLine(200,200,300,300);
Output:
Develop a program to implement drawRect() and fillRect() methods of
applet.
/* <applet code=saee_applet2.class width=500 height=500></applet>*/
importjava.applet.*;
importjava.awt.*;
g.drawString("Rectangle", 10,10);
g.drawRect(20,20,70,50);
g.fillRect(100,20,70,50);
}
Develop a program to implement drawRoundRect() and fillRoundRect()
methods of applet.
importjava.applet.*;
importjava.awt.*;
g.drawRoundRect(20,20,50,50,10,10);
g.fillRoundRect(90,20,50,50,10,10);
}
Develop a program to implement drawOval() and fillOval() methods of
applet.
importjava.applet.*;
importjava.awt.*;
g.drawString("Oval", 10,10);
g.drawOval(20,20,50,70);
g.fillOval(80,20,50,70);
}
Develop a program to implement drawArc() method of applet.
importjava.applet.*;
importjava.awt.*;
g.drawString("Arc", 270,270);
g.drawArc(250,250,50,50,180,180);
}
Develop a program to implement drawPolygon() method of applet.
importjava.applet.*;
importjava.awt.*;
g.drawString("Polygon", 10,10);
g.setColor(Color.red);
int x1[]={10,170,80,10};
int y1[]={20,40,140,20};
int n=x1.length;
g.setColor(Color.red);
g.drawPolygon(x1,y1,n);
}
Develop a program using control loops in applet.
/* <applet code=saee_applet2.class width=500 height=500></applet>*/
importjava.applet.*;
importjava.awt.*;
for(int i=0;i<=2;i++)
if(i%2==0)
g.drawOval(120,i*60+10,50,50);
else
g.fillOval(120,i*60+10,50,50);
}
Output: