Applet

From BC$ MobileTV Wiki
Jump to: navigation, search
Java (cup of java) Logo
Applet & JNLP Java WebStart icon

Applet is a legacy Java technology for embedding and presenting dynamic/interactive code & interface components into HTML rendered by a browser, achieving one of the earliest RIA stacks. The term Applet is most commonly used to describe technology originally released by Sun for the Java programming language, designed to run in an end-user's browser client.


Specifications

[1]


AWT

[2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]


Java Applet

The method below shows how to embed an Applet on an HTML page using the deployJava JavaScript helper utility from Sun Microsystems/Oracle, which was during the peak of their lifetime, the recommended way of interacting with and using applets (along with traditional fallbacks to the straight Object/Embed and Applet custom tag methods, for browsers with JavaScript and/or embedded objects disabled or otherwise unavailable):

 <script src="http://java.com/js/deployJava.js"></script>
 <script>
    var attributes = {codebase:'http://java.sun.com/products/plugin/1.5.0/demos/jfc/Java2D',
                      code:'java2d.Java2DemoApplet.class',
                      archive:'Java2Demo.jar',
                      width:710, height:540} ;
    var parameters = {fontSize:16} ;
    var version = '1.6' ;
    deployJava.runApplet(attributes, parameters, version);
 </script>
 <noscript>
   <object type="application/x-java-applet;version=1.5.0" codebase="http://java.sun.com/products/plugin/1.5.0/demos/jfc/Java2D" width="710" height="540">
     <param name="archive" value="Java2Demo.jar" />
     <param name="code" value="java2d.Java2DemoApplet.class" />
     <param name="backgroundcolor" value="FFFFFF" />
     <embed type="application/x-java-applet;version=1.5.0" codebase="http://java.sun.com/products/plugin/1.5.0/demos/jfc/Java2D" archive="Java2Demo.jar" code="java2d.Java2DemoApplet.class" width="710" height="540">
       <noembed>
         <applet archive="Java2Demo.jar" code="java2d.Java2DemoApplet.class" width="710" height="540">
           <param name="backgroundcolor" value="FFFFFF" />
         </applet>
       </noembed>
     </embed> 
   </object>
 </noscript>



Deprecated simple method (no longer works in many modern browsers):

 <applet width=300 height=300 code="MyCoolApplet.class">
   <param name="background" value="FFFFFF"></param>
   <param name="shadowcolor" value="FFFFFF"></param>
   ...
     <img src="MyCoolApplet.jpg" title="You need to enable Java to see this applet." />
 </applet>

The above code basically says you have an Applet that you want to display with a width of 300 (pixels) and height of 300 (pixels), and with a Java class that generates the applet named "MyCoolApplet" (where MyCoolApplet.java is some Java code which has already been compiled into MyCoolApplet.class. It also accepts some parameters as specified by the <param> tag, which represent a name and value pair; for example "background" for the color of this applet's background, in this case set to FFFFFF or white (notice it does not use the opening "#" as in "#FFFFFF" hash to represent the color value as a hexadecimal number as CSS and HTML styles use). (NOTE: you can not, however, use the MyCoolApplet.java code directly in the applet, this will result in a rendering error and either the fallback image of the applet within the <applet> tags, or the default empty applet window, or nothing, depending on the browser.)



EXAMPLES

Tools


Resources


Tutorials


External Links

References

  1. Flash Satay - Embedding Flash While Supporting Standards: https://alistapart.com/article/flashsatay/
  2. Introduction to the AWT -- description of Java's user interface toolkit: https://www.javaworld.com/article/2077188/introduction-to-the-awt.html
  3. Java AWT Tutorial: https://www.javatpoint.com/java-awt
  4. The "new" AWT Tutorial: http://www.eng.auburn.edu/~rayh/java/java/AWT.Tutorial.html (top tutorial back in 1995-1996 when AWT first came out)
  5. Overview of the AWT: https://staff.fnwi.uva.nl/a.j.p.heck/Courses/JAVAcourse/ch5/s1.html
  6. Java AWT tutorial for beginners: https://beginnersbook.com/2015/06/java-awt-tutorial/
  7. AWT Tutorial: https://www.tutorialspoint.com/awt/ | PDF
  8. Java AWT Graphics Example: https://examples.javacodegeeks.com/desktop-java/swing/java-awt-graphics-example/
  9. "Java in a Nutshell", by David Flanaga (BOOK): http://web.deu.edu.tr/doc/oreily/java/javanut/index.htm | AWT changes section (Freely available online now)
  10. "Java AWT Reference", by John Zukowski (BOOK): https://www.oreilly.com/library/view/java-awt-reference/9781565922402/
  11. Brewing Java - A Tutorial: http://www.cafeaulait.org/javatutorial.html (from 1990s Java approaches... in 2019 not THAT different, well except for Lambdas/Functional stuff)
  12. Java AWT Code Examples: https://java.happycodings.com/java-awt/
  13. Java Code Examples for java.awt.Frame: https://www.programcreek.com/java-api-examples/java.awt.Frame
  14. jlGui - Music Player (JNLP Launch file configurator for standalone desktop application version): http://www.javazoom.net/jlgui/jnlp_configurator.jsp
  15. Two Player Pong: http://www.jdonohue.com/java/pong/two_player_pong/two_player_pong.html
  16. Pong Applet:http://forums.devshed.com/java-help-9/pong-applet-667776.html
  17. http://javaboutique.internet.com/SimplePong/
  18. http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=3234&lngWId=2
  19. How to Form a TCP Connection Between a JavaScript Program and Java Server: http://pharos.ece.utexas.edu/wiki/index.php/How_to_Form_a_TCP_Connection_Between_a_JavaScript_Program_and_Java_Server
  20. StephenWare's Java-JS Socket Bridge (Fork with minor improvements): http://github.com/ihilt/JavaSocketBridge
  21. Running an Applet in Netbeans: https://ubuntuforums.org/showthread.php?t=872378
  22. Invoking Applet Methods From JavaScript Code: http://download.oracle.com/javase/tutorial/deployment/applet/invokingAppletMethodsFromJavaScript.html
  23. Oracle Reminds Java Developers That Soon They Won’t Have a Browser to Run Applets: https://www.infoq.com/news/2017/02/oracle-java-browser-applet

See Also

Java | JavaFX | J2ME | Widget