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

Difference between nested and inner classes ?

0 Answers  


Explain java coding standards for methods?

0 Answers  


What is bool mean?

0 Answers  


What is the difference between Java and C++?

0 Answers   Integreon, TCS, ZS Associates,


Why lambda expression is used in java?

0 Answers  






hi to all,i have a question on static block. i saved below as test.java class test extends a { static { System.out.println("test static"); } public static void main(String []dfs) { } } class a { static { System.out.println("a static"); } public static void main(String []asdf) { } } o/p as static test static but if i change base class as test class then class test { static { System.out.println("test static"); } public static void main(String []dfs) { } } class a extends test { static { System.out.println("a static"); } public static void main(String []asdf) { } } o/p test static explain me why "a static" wasn't print in second code when it is in derived class

1 Answers  


What is the life cycle of an Applet ?

1 Answers  


How to prevent a field from serialization ?

2 Answers  


Can we use static class instead of singleton?

0 Answers  


Is void a type?

0 Answers  


Which is faster set or list in java?

0 Answers  


Which java version is latest?

0 Answers  


Categories