Skip to content

Instantly share code, notes, and snippets.

@Jegp
Created July 29, 2012 11:40
Show Gist options
  • Save Jegp/3197935 to your computer and use it in GitHub Desktop.
Save Jegp/3197935 to your computer and use it in GitHub Desktop.
Java Applet deployment in HTML
<html>
<body>
<!-- See this link for explanation: http://docs.oracle.com/javase/1.5.0/docs/guide/plugin/developer_guide/using_tags.html -->
<object classid="clsid:CAFEEFAC-0015-0000-0000-ABCDEFFEDCBA">
<param name="code" value="AppletTest.class">
<comment>
<embed code="AppletTest.class"
type="application/x-java-applet;jpi-version=1.7.0">
<noembed>
No Java Support.
</noembed>
</embed>
</comment>
</object>
</body>
</html>
import java.applet.*;
import java.awt.*;
/**
* A test on how to create an applet.
*/
public class AppletTest extends Applet {
/**
* This method is run when the applet instance is ready to be run in the browser.
*/
public void init() {
// Set variables, request focus, setup AWT/Swing components and pack() here.
}
/**
* This method draws the applet.
*/
@Override public void paint(Graphics graphics) {
// Remember to paint the inherited methods (and the containers)
super.paint(graphics);
// Paint random stuff
graphics.setColor(Color.black);
graphics.drawString("Hello World!", 50, 50);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment