Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help forApplet

 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
This is Kajol here....and I am new to this foroum....I am going through TIJ and was reading the applets and had problem in the begining ....
I tried to view the following applet:
import javax.swing.*;
import java.awt.*;
public class Applet1b extends JApplet {
public void init() {
getContentPane().add(new JLabel("Applet!"));
}
} ///:~
The html file was as follows....
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<applet code="Applet1b.java" width="100" height="50" name="Applet1b">
</applet>

</body>
</html>
when I try to view this applet in teh browser...it gives me error..
Can anybody tell me where am I going wrong...I can view the applet in teh appletviewer...
Please reply
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kajol,
The type of Applet you made is a JApplet, which is based on Swing... most popular browsers do not support Swing so you will need to download the Java 2 plugin from Sun ( http://java.sun.com/products/plugin/index.html ) and define your applet with the object tag in your webpage rather than with the applet tag. A JApplet should also run fine in appletviewer, the program that comes with the JDK for testing applets.
HTH,
-Nate
 
Val Dra
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you will need to download htmlConverted from Sun which will also convert your htmlfile and generate a plugin code for it so your applet will be able to run in the browser. Users might experience some delays using your applet it's takes some time to download the plugin for them.
 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Nathan & Val,
I tried running the applet1.html file through the HTML converter and it worked.....cool .............
I was really happy after that........
Thanks a lot.......
Kajol
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic