Created
July 29, 2012 11:40
-
-
Save Jegp/3197935 to your computer and use it in GitHub Desktop.
Java Applet deployment in HTML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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