Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

applet related confusion

 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the book its said that applet can be used in source code too,instead of writing it again ang again in HTML pages...

and the code was like follows

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

/*<APPLET
Code=applet4.class
WIDTH=200
HEIGHT=200>
</APPLET>
*/
public class applet4 extends Applet
{
public void paint(Graphics g)
{
g.drawString("Hello",60,100);
}
}

how how will this code used in any HTML page?
 
Rob Spoor
Sheriff
Pie
Posts: 20526
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Applets.
 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime didnt get you
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It won't be used in any HTML page - it's for development and testing purposes only. If you embed the applet tag in the Java source code like his, then you can use appletviewer to run the applet by typing "appletviewer applet4.java". That's because appletviewer doesn't care about the rest of the file - it only looks for the applet tag.

If you want to deploy the applet for others to use, then you do need a proper HTML page (which would contain the same applet tag).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic