i m new to java...i made my first applet...a simple applet to showing "THIS IS MY FIRST APPLET"..but it's not working...i m not able to see it in mozilla firefox and IE7...
plz help..
the code is here...

tryApplet.java

import java.awt.Font;
import java.awt.Color;
import java.awt.Graphics;

public class tryApplet extends java.applet.Applet
{
Font f=new Font("Garamond",Font.BOLD+Font.ITALIC,30);

public void pain(Graphics g)
{
g.setFont(f);
g.setColor(Color.blue);
g.drawString("THIS IS MY FIRST APPLET....",10,40);
}
}

first.htm

<html>
<head>
<title>Testing Applet</title>
</head>

<body>
<p>
This is my first Applet<br>

<applet code="tryApplet.class" width=400 height=200>
THIS WILL BE PRINTED IF YOUR BROWSER DOES NOT SUPPORT JAVA
</applet>


</body>
</html>

@Ezzaral..

thanks...it was a silly mistake..it worked...

well i want to ask one more question ...i m using jCreator for this...if i want to run it using command prompt i have to change the directory to bin folder of jdk everytime i run cmd...

how can i set path for this forever...

@lamthwee
ya they are in same folder..

but if they are in different folder can i use
<applet code="E:\rajat\My files\java progs\tryApplet.class"..>

means can i set path in applet tag...

@Ezzaral
well one more thing i wanna ask
why didnt it give a compile time error...

@Ezzaral..

thanks...it was a silly mistake..it worked...

well i want to ask one more question ...i m using jCreator for this...if i want to run it using command prompt i have to change the directory to bin folder of jdk everytime i run cmd...

how can i set path for this forever...

Add your Java /bin folder to the system path in your environment variables. This is described in more detail here if you need it: http://java.sun.com/javase/6/webnotes/install/jdk/install-windows.html#Environment

@Ezzaral
well one more thing i wanna ask
why didnt it give a compile time error...

It did not complain because your method was still a valid one - just not the one that you wanted to override. You supplied an new method called pain() and the compiler was just fine with that.

This question has already been answered. Start a new discussion instead.