how to create an applet

Answers were Sorted based on User's Feedback



how to create an applet..

Answer / akansha

Here is the java code of program :

import java.applet.*;
import java.awt.*;

public class FirstApplet extends Applet{
public void paint(Graphics g){
g.drawString("Welcome in Java Applet.",40,20);
}
}


Here is the HTML code of the program:

<HTML>
<HEAD>
</HEAD>
<BODY>
<APPLET ALIGN="CENTER" CODE="FirstApplet.class" WIDTH="800"
HEIGHT="500"></APPLET>
</BODY>
</HTML>

Is This Answer Correct ?    1 Yes 0 No

how to create an applet..

Answer / krishgopal

import java.applet.*;
import java.awt.*;

/*
<applet code="app" width=400 height=500>
</applet>
*/

public class app extends Applet {
public void paint(Graphics g)
{
g.drawString("hi java",100,200);
}
}

here we use applet pack to retrive all its mathods
to create an applet.
and awt to create window events.
all that u known.
paint() is to paint the page that means
create a page and putting everything on it.
"hi java" is a string to dispaly on sgrren and
100,200 are x &y axis' to the text where to
dispaly on screen.

applet code is must to disply an applet prgrm.
width=400 height=500 r size of dispalying screen.

we can dispaly applet prgrm in any browser
with use of HTML prgrm.
for more details just refer "complete reference" book.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Is it possible for a yielded thread to get chance for its execution again?

0 Answers  


what is inner class in java?

0 Answers   IBS,


What happens if a try-catch-finally statement does not have a catch clause to handle an exception that is thrown within the body of the try statement?

0 Answers  


What is difference between overloading and overriding in java?

0 Answers  


What are the differences between graph and tree?

0 Answers   Amazon,






What are virtual methods?

1 Answers   TCS,


How do you sort in java?

0 Answers  


WAP to illustrate the use of interface

2 Answers  


How variables are declared?

0 Answers  


What is complexity in java?

0 Answers  


What do you mean by checked exceptions?

0 Answers  


What are the advantages of java over C++?

0 Answers  


Categories