Tags

, , , ,

Class Hierarchy for Applet

1.The AWT have many graphic component. When we start writing any applet program ,must right this two packages names.

• java.awt
• java.applet
2. The java.applet packege have class Applet which have AppletContext, AppletStub and AudioClip. The applet class is extension of panel belonging to java.awt.
3. To create GUI window we need differnet components.
COMPONENT class which have some class for components. Like                     CHECKBOX, CHOICE, LIST, BUTTON etc etc
• The COMPONENT class in java.awt is in abstract class.

Capture2
Continue reading

what is applet? Gtu

Tags

, , , , , ,

Interoduction of Applet

  • In java there are two types of programs 1.java aplication programs and 2. Applet. Whwere java application program resembleds any compiled language.
  • Example of progam is:
    class demo{

    public static void main(String args[]){

                                    System.out.println(“Hello!Demo!”)

    }             

    }

  • But other type of java program is applet. Applet are small parts of program which run as of webdocs.
  • Most of use of applet access from server side.it’s transfer from internet to user computer and automatically installed and run. Its used for multimedia interface. Applet coding as far different than java application.
  • Example of progam is:
    import java.awt.*;

    import java.applet.*;

    public class FirstDemoApplet extends Applet{

                    public void paint(Graphics g){

                                    g.drawstring(“FirstDemoApplet string”,50,30);

    }

    }

  • Lets applet programming:
    1. We always need two packages to imported in program. That is java.awt and java.applet.
    2. Where java.awt store component of awt classes. Its support for windows based GUI such as for drawing,screen,window, btton, textbox, menus etc.etc.
    3. And java.applet, this must need in applet program becuase, its store component in applet class. That have functionalities to run applet in web browser
    4. Then comes public class FirstDemoApplet extends Applet where FirstDemoApplet is subclass of class Applet. So that extends is used.first class need to public to run applet program.
    5. Public void paint(Graphic g) this method which painting something, its can be text, circle, rectangle, line anything.
    6. This menthod need pass perameter so passed object of class graphics is g. Using object method drawstring to display string,which is graphics class is invoked. Where 50.30 define the position of string , respectively x axis and yaxis.

Continue reading

Drop down link box

Tags

, , ,

This Javascript-enabled select box is  access to multiple pages without using up lots of screen-space.
An effortlessly cool way to get around. You can use this code to link to different pages; or to link to specific sections of the same page

CODE:

<script type="text/javascript">
<!--
// original code by Bill Trefzger 12/12/96
function go1(){
if (document.selecter1.select1.options[document.selecter1.select1.selectedIndex].value != "none") {
location = document.selecter1.select1.options[document.selecter1.select1.selectedIndex].value
		}
	}
//-->
</script>
<script type="text/javascript">
<!--
document.write('



');
document.write('

Select your destination');
document.write('

--------------------');
document.write('

Page 1');
document.write('

Page 2');
document.write('

Page 3');
document.write('


');
document.write('  ');
document.write('


');
// end hiding contents -->
</script>
save this script in your html page. that will work like this

//
// <![CDATA[
document.write('

‘);
document.write(‘

Select your destination’);
document.write(‘

——————–‘);
document.write(‘

AnimationBuddyzz’);
document.write(‘

gturockstar’);
document.write(‘

tips for beginner’);
document.write(‘

‘);
document.write(‘ ‘);
document.write(‘

‘);
// end hiding contents
// ]]>

80. Program to read a string and print the number of characters in each word of the string.

Tags

, , , , ,

#include<stdio.h>

#include<conio.h>

#include<string.h>

main( ){

char s[100];

int i,l,nc=0;

clrscr( );

printf(“enter the sting”);

gets(s);

l=strlen(s);

for(i=0;i<l;i++){

if(s[i]!=’ ‘){

nc=0;

while(s[i]!=’ ‘){

nc++;

printf(“%c”,s[i]);

i++;

if(s[i]=”)

break;

}

printf(“\t\t %d”,nc);

printf(“\n”);

}

}

getch();

}

81. Program to accept two strings and compare those two strings

Tags

, , , , ,

#include<stdio.h>

#include<conio.h>

int strcomp (char *pt1, char *pt2);

void read-string(char*pt);

main( ){

char line [80],line2[80];

clrscr( );

printf(“enter first string;”);

read-string (line1);

printf(“enter second string”);

read-string(line2);

if(strcomp (line1,line2)>0)

printf(“second string biggest”);

else

if(strcomp (line1,line2)>0)

printf(” first string biggest;”);

else

printf(“both the strins are equal”);

getch( );

}

void read-string(char*pt)

{

for(;(*pt=getchar( ))!=’\n’;pt++);

*pt=”;

}

int strcomp (char *pt1, char *pt2)

{

for(;*pt1!=”;pt1++;pt2++)

if(*pt1!=*pt2)

break;

return *pt1-*pt2;

}

83.Program to read a string and print the first two characters of each word in the string.

Tags

, , , , ,

#include<stdio.h>

#include<conio.h>

main( )

{

char s[100];

int i,l;

clrscr( );

printf(“enter a string”);

gets(s);l=strlen(s);

for(i=0;i<l;i++)

{

if(s[i]!=’ ‘ && s[i]=’ ‘)

{

printf(“%c %c”,s[i],s[i+1])

i=i+2;

while(s[i]!=’ ‘)

i++;

}

}

getch( );

}

86. Program to accept two 3 dimensional array and store subtraction of those two arrays into third array..

Tags

, , , , ,

#include<stdio.h>

#include<conio.h>

main( ){

int a[3][3],b[3][3],c[3][3],i,j;

clrscr( );

for(i=0;i<3;i++)

for(j=0;j<3;j++){

printf(“enter two values for a[%d][%d] &

b[%d][%d]:”,i,j,i,j);

scanf(“%d%d”,&a[i][j],&b[i][j]);

}

for(i=0;i<3;i++){

for(j=0;j<3;j++){

c[i][j]=a[i][j]-b[i][j];

printf(“%d”,,c[i][j]);

}

printf(“\n”);

}

getch( );

85.Program to accept a string and print reverse of the given string by using functions.

Tags

, , , , ,

 

#include<stdio.h>

#include<stdio.h>

int getline (char str[]);

void printline (char str[],int i);

main( ){

char str[80];

int 1;

clrscr( );

1=getline(str );

printline(str,1);

printline(str,1);

getch ( );

}

int getline(char str[]){

int 1;

printf(“enter a string;”);

for(i=0;i<80&&((str[i]=getchar())!=’\n’);i++);

if(str[i]=”;

return i;

}

void printline(char str[],int 1){

int j;

for(j=1;j<=0;j–)

printf(“%c”,str[j]);

printf(‘is the revefrse string”);

}