{"id":73,"date":"2020-12-31T22:05:59","date_gmt":"2020-12-31T22:05:59","guid":{"rendered":"https:\/\/bhiggs.x10hosting.com\/practical-java-programming\/?page_id=73"},"modified":"2021-01-13T20:08:56","modified_gmt":"2021-01-13T20:08:56","slug":"applets","status":"publish","type":"page","link":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/course-topics\/applets\/","title":{"rendered":"Applets"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_83 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a06ed40dc4f1\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a06ed40dc4f1\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/course-topics\/applets\/#Applet_Security_Constraints\" >Applet Security Constraints<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/course-topics\/applets\/#Testing_Applets\" >Testing Applets<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/course-topics\/applets\/#The_Class_Hierarchy\" >The Class Hierarchy<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/course-topics\/applets\/#A_Simple_Applet\" >A Simple Applet<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/course-topics\/applets\/#HTML_Tags_for_Applets\" >HTML Tags for Applets<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/course-topics\/applets\/#Adding_Package_Directory_Specifications\" >Adding Package &amp; Directory Specifications<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/course-topics\/applets\/#The_Applet_Life_Cycle\" >The Applet Life Cycle<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/course-topics\/applets\/#Multimedia_URLs\" >Multimedia &amp; URLs<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/course-topics\/applets\/#The_Java_URL_Class\" >The Java URL Class<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/course-topics\/applets\/#getDocumentBase_and_getCodeBase\" >getDocumentBase() and getCodeBase()<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/course-topics\/applets\/#getImage_and_getAudioClip\" >getImage() and getAudioClip()<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/course-topics\/applets\/#Applet_Context\" >Applet Context<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/course-topics\/applets\/#Converting_Applications_to_Applets\" >Converting Applications to Applets<\/a><\/li><\/ul><\/nav><\/div>\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>NOTE:<\/strong> <strong>Java applets have been\u00a0deprecated\u00a0since Java 9 in 2017, and were removed from Java SE (Standard Edition) 11 (18.9), released in September 2018.<br><br>This means that, while you may find learning about Java applets to be interesting, it won&#8217;t get you far today in practical web applications using Java. <br><br>There are various alternatives, but most of them come down to using JavaScript in some way or another.<br><br><a rel=\"noreferrer noopener\" href=\"http:\/\/www.gwtproject.org\/\" target=\"_blank\">GWT<\/a> is an interesting project that you might find useful. It allows you to write Java code using a predetermined set of classes, and basically translate them into JavaScript code for use on the web. It&#8217;s open source, and totally free.<\/strong><\/p><\/blockquote>\n\n\n\n<p>Way back when, in the original release of Java, <em>applets<\/em> were a big deal.&nbsp; At the time, HTML web pages were regarded as rather static, and any technology that added a dynamic aspect to HTML web pages was considered goodness.<\/p>\n\n\n\n<p>Over the years, however, applets have become less and less important to Java.&nbsp; Much of this was a result of the browser wars between Netscape and Microsoft, and the negative consequences of those wars still linger today.&nbsp; Another reason was that other technologies have evolved to make web pages more dynamic.<\/p>\n\n\n\n<p>Many books on Java use applets heavily in their examples.&nbsp; I have avoided that, because I have found that learning the various quirks and foibles of different web browsers just to get an applet to work tended to get in the way of learning Java itself.&nbsp; So, most of my examples use Java applications, which are simpler to get working because you don&#8217;t have to fight the browser as well as the language.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Applet_Security_Constraints\"><\/span>Applet Security Constraints<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Applets run within a browser, subject to the constraints of a security manager.<\/p>\n\n\n\n<p>In JDK 1.0.x, applets loaded over the web were completely constrained:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>No reading, or writing, or deleting, or getting information about local files.<\/li><li>No running another program.<\/li><li>No loading of a Java library<\/li><li>No connection to a server other than the one the applet was loaded from.<\/li><li>etc&#8230;<\/li><\/ul>\n\n\n\n<p>In JDK 1.1.x, and beyond, applets may be trusted as a result of being&nbsp;<em><strong>signed<\/strong>&nbsp;<\/em>&#8212; they may carry a secure certificate that identifies the source of the applet, and verifies that the source may be&nbsp;<em><strong>trusted<\/strong><\/em>.&nbsp; Unfortunately, Netscape&#8217;s way of signing applets is not compatible with Microsoft&#8217;s way, and vice versa.&nbsp; This has been solved with the use of the Sun Java Plug-in.<\/p>\n\n\n\n<p>Customizable security levels are already implemented in some browsers, but signed applet support requires JDK 1.1.x support (or above) in the browser.<\/p>\n\n\n\n<p>With each version of Java has come an increased level of granularity in terms of the ability to control what a particular trusted applet is allowed to do.&nbsp; Initially, with JDK 1.1, applets could be either untrusted, or completely trusted.&nbsp; Later versions of Java allowed more ability to specify exactly what a trusted applet could, or could not, do.<\/p>\n\n\n\n<p>Today, modern browsers use the <em>Java Plug-in<\/em>, which allows the browser to support completely up to date versions of Java.&nbsp; However, this does mean that someone has to download and install the Java Plug-in for some browsers (notably Microsoft Internet Explorer).&nbsp; Since the Java Plug-in is rather large, this can be a non-trivial task.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Testing_Applets\"><\/span>Testing Applets<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>While you&#8217;re developing applets, you can try them out in a browser, but debugging is likely to be done within an applet viewer:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The JDK comes with a standard&nbsp;<code><strong>appletviewer<\/strong><\/code>&nbsp;program<\/li><li>Various Java IDEs may provide their own equivalent to <em>appletviewer<\/em>, and also add the ability to debug applets using their debugger.<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"The_Class_Hierarchy\"><\/span>The Class Hierarchy<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Here&#8217;s the class hierarchy for applications and applets:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>Object\n   Component\n      Container\n         Window\n            Frame  \/\/ base for applications\n         Panel\n            Applet \/\/ base for applets\n               JApplet<\/strong><\/pre>\n\n\n\n<p>An&nbsp;<code><strong>Applet<\/strong><\/code>(and a&nbsp;<code><strong>JApplet<\/strong><\/code>) is a kind of&nbsp;<code><strong>Panel<\/strong><\/code>, which is a kind of&nbsp;<code><strong>Container<\/strong><\/code>, etc.<\/p>\n\n\n\n<p>Not so different from what we&#8217;ve seen before, right?<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"A_Simple_Applet\"><\/span>A Simple Applet<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Here&#8217;s a trivial applet:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; auto-links: false; highlight: [5,9]; title: ; quick-code: false; notranslate\" title=\"\">\npackage applets;\n\nimport java.awt.Container;\n\nimport javax.swing.JApplet;\nimport javax.swing.JLabel;\nimport javax.swing.SwingConstants;\n\npublic class GreetApplet extends JApplet\n{\n  public void init()\n  {\n    Container contentPane = getContentPane();\n    JLabel label = \n        new JLabel(&quot;Greetings from a Java applet&quot;,\n                   SwingConstants.CENTER);\n    contentPane.add(label);\n  }\n}\n<\/pre><\/div>\n\n\n<p>Unfortunately, I can&#8217;t show you how it displays in a browser because applets have been removed from Java and from pretty much all browsers.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong><em>Note:&nbsp;<\/em><\/strong>Versions are important when writing applets.&nbsp;For example, when I first wrote the above applet, I wrote it and compiled it using JDK 1.5 .&nbsp; However, when I tried it in one of my browsers that had a Java 1.4 plug-in, my browser failed to load the applet successfully.&nbsp; I looked in the Java Plug-in&#8217;s Console, and it told me that it had encountered an error:<br><br><strong>java.lang.UnsupportedClassVersionError: applets\/GreetApplet      (Unsupported major.minor version 49.0)<\/strong><br><br>Self-descriptive message, don&#8217;t you think? When I investigated further, I discovered that I could not run the code I had written under JDK 1.5 using a Java Plug-in 1.4 (or earlier).&nbsp; So, I changed the source code to ensure I wasn&#8217;t using any JDK 1.5 specific features, and then compiled it under JDK 1.4.&nbsp; The resulting version now runs using both the 1.4 and 1.5 versions of the Java Plug-in.<\/p><\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"HTML_Tags_for_Applets\"><\/span>HTML Tags for Applets<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>To embed an applet within a web page, you must use an appropriate set of HTML tags:<\/p>\n\n\n\n<p>Here&#8217;s the HTML for a very simple web page with an embedded applet:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; highlight: [7,8,9,10,11,12,13]; title: ; notranslate\" title=\"\">\n&lt;html&gt;\n&lt;head&gt;\n&lt;title&gt;I&#039;m a Java-enabled Web Page!&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n Here&#039;s the Java applet:\n &lt;applet code=&quot;MyApplet.class&quot;\n\t width=&quot;300&quot;\n\t height=&quot;200&quot;\n &gt;\n Sorry, you&#039;re out of luck!\n Your browser doesn&#039;t support Java.\n &lt;\/applet&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre><\/div>\n\n\n<p>As you can see, there&#8217;s a single tag,&nbsp;<code><strong>&lt;applet&gt; ... &lt;\/applet&gt;<\/strong><\/code>&nbsp;which has a number of attributes that can be specified.<\/p>\n\n\n\n<p>Here are the named attributes for the&nbsp;<code><strong>&lt;applet&gt;<\/strong><\/code>&nbsp;tag for JDK 1.0.x:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Attribute name<\/th><th>Required?<\/th><th>Description<\/th><\/tr><tr><td><code>CODE=\"foo.class\"<\/code><\/td><td>Yes<\/td><td>Specifies the name of the applet&#8217;s .class file.<\/td><\/tr><tr><td><code>WIDTH=pixels<\/code><\/td><td>Yes<\/td><td>Specifies the width of the applet window<\/td><\/tr><tr><td><code>HEIGHT=pixels<\/code><\/td><td>Yes<\/td><td>Specifies the height of the applet window<\/td><\/tr><tr><td><code>CODEBASE=\"path\"<\/code><\/td><td>No<\/td><td>Specifies where to find the .class files, relative to the location of the enclosing HTML page.<\/td><\/tr><tr><td><code>NAME=\"applet-name\"<\/code><\/td><td>No<\/td><td>Specifies the name of the applet (used to distinguish it from other applets on the same page).<\/td><\/tr><tr><td><code>ALIGN=LEFT<\/code><\/td><td>No<\/td><td>Places the applet at the left margin of the page. Text that follows goes in the space to the right of the applet.<\/td><\/tr><tr><td><code>ALIGN=RIGHT<\/code><\/td><td>No<\/td><td>Places the applet at the right margin of the page. Text that follows goes in the space to the left of the applet<\/td><\/tr><tr><td><code>ALIGN=BOTTOM<\/code><\/td><td>No<\/td><td>Places the bottom of the applet at the bottom of the text in the current line.<\/td><\/tr><tr><td><code>ALIGN=TOP<\/code><\/td><td>No<\/td><td>Places the top of the applet with the top of the current line.<\/td><\/tr><tr><td><code>ALIGN=TEXTTOP<\/code><\/td><td>No<\/td><td>Places the top of the applet with the top of the text in the current line.<\/td><\/tr><tr><td><code>ALIGN=MIDDLE<\/code><\/td><td>No<\/td><td>Places the middle of the applet with the baseline of the current line.<\/td><\/tr><tr><td><code>ALIGN=ABSMIDDLE<\/code><\/td><td>No<\/td><td>Places the middle of the applet with the middle of the current line.<\/td><\/tr><tr><td><code>ALIGN=BASELINE<\/code><\/td><td>No<\/td><td>Places the bottom of the applet with the baseline of the current line.<\/td><\/tr><tr><td><code>ALIGN=ABSBOTTOM<\/code><\/td><td>No<\/td><td>Places the bottom of the applet with the bottom of the current line.<\/td><\/tr><tr><td><code>VSPACE=pixels<\/code><\/td><td>No<\/td><td>Creates a vertical margin around the applet .<\/td><\/tr><tr><td><code>HSPACE=pixels<\/code><\/td><td>No<\/td><td>Creates a horizontal margin around the applet.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Here are the&nbsp;<code><strong>&lt;applet&gt;<\/strong><\/code>&nbsp;tag attributes added for JDK 1.1.x:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Attribute name<\/th><th>Required?<\/th><th>Description<\/th><\/tr><tr><td><code>ARCHIVE=\"jar-file\"<\/code><\/td><td>No<\/td><td>Specifies the name of a Java archive (JAR) file that contain classes and other resources for the applet.<\/td><\/tr><tr><td><code>OBJECT=\"obj-file\"<\/code><\/td><td>No<\/td><td>Specifies the name of a file that contains the serialized applet object.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Adding_Package_Directory_Specifications\"><\/span>Adding Package &amp; Directory Specifications<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The above HTML example is very basic:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>It specifies an applet whose&nbsp;<code><strong>.class<\/strong><\/code>&nbsp;file is&nbsp;<em>in the same directory as its enclosing HTML page file.<\/em><\/li><li>The class whose&nbsp;<strong><code>.class<\/code>&nbsp;<\/strong>file is being used is&nbsp;<em>in the default package.<\/em><\/li><\/ul>\n\n\n\n<p>Think of the&nbsp;<code><strong>CODEBASE<\/strong><\/code>&nbsp;attribute as specifying a kind of&nbsp;<code><strong>CLASSPATH<\/strong><\/code>&nbsp;for the applet. The same kind of rules apply to applets as apply to applications, when you start dealing with classes within packages.<\/p>\n\n\n\n<p>To specify an applet whose&nbsp;<code><strong>.class<\/strong><\/code>&nbsp;file is in subdirectory&nbsp;<code><strong>classes<\/strong><\/code>, and whose class is in the default package:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; auto-links: false; highlight: [8]; title: ; quick-code: false; notranslate\" title=\"\">\n&lt;html&gt;\n&lt;head&gt;\n&lt;title&gt;I&#039;m a Java-enabled Web Page!&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n Here&#039;s the Java applet:\n &lt;applet code=&quot;MyApplet.class&quot;\n\t codebase=&quot;classes&quot;\n\t width=&quot;300&quot;\n\t height=&quot;200&quot;\n &gt;\n Sorry, you&#039;re out of luck!\n Your browser doesn&#039;t support Java.\n &lt;\/applet&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre><\/div>\n\n\n<p>To specify an applet whose class is in the package&nbsp;<code><strong>myPackage<\/strong><\/code>:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; highlight: [7]; title: ; notranslate\" title=\"\">\n&amp;lt;html&gt;\n&amp;lt;head&gt;\n&amp;lt;title&gt;I&#039;m a Java-enabled Web Page!&amp;lt;\/title&gt;\n&amp;lt;\/head&gt;\n&amp;lt;body&gt;\n Here&#039;s the Java applet:\n &amp;lt;applet code=&quot;myPackage.MyApplet.class&quot;\n         codebase=&quot;classes&quot;\n\t width=&quot;300&quot;\n\t height=&quot;200&quot;\n &gt;\n Sorry, you&#039;re out of luck!\n Your browser doesn&#039;t support Java.\n &amp;lt;\/applet&gt;\n&amp;lt;\/body&gt;\n&amp;lt;\/html&gt;\n<\/pre><\/div>\n\n\n<p>and the&nbsp;<code><strong>.class<\/strong><\/code>&nbsp;file must be in subdirectory below where the document is:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>classes\/myPackage<\/strong><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"The_Applet_Life_Cycle\"><\/span>The Applet Life Cycle<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Here is a state transition diagram showing the possible states of an applet, during its lifetime:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignleft size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"482\" height=\"250\" src=\"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-content\/uploads\/2021\/01\/appletLife.gif\" alt=\"\" class=\"wp-image-1240\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:17px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>The four applet methods that cause state transitions are:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Method<\/th><th>Description<\/th><\/tr><tr><td><code>init()<\/code><\/td><td>Called when the applet is first loaded into the browser. Performs applet initialization. Called once only.<\/td><\/tr><tr><td><code>start()<\/code><\/td><td>Called after the init() method has completed. Also called when the browser opens the page again after having read other pages. Can be called many times.<\/td><\/tr><tr><td><code>stop()<\/code><\/td><td>Called when the browser moves off the page. Can be called many times.<\/td><\/tr><tr><td><code>destroy()<\/code><\/td><td>Called with the applet is about to be unloaded from the browser. Performs resource cleanup. Called once.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Multimedia_URLs\"><\/span>Multimedia &amp; URLs<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Multimedia includes:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>images<\/li><li>audio<\/li><li>video<\/li><li>etc&#8230;<\/li><\/ul>\n\n\n\n<p>A URL (<em>Uniform Resource Locator<\/em>) is a description of a resource on the Internet. Here is an&nbsp;<em>absolute URL<\/em>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>protocol:\/\/host.domain[:port]\/path\/filename<\/strong><\/pre>\n\n\n\n<p>where&nbsp;<code>protocol<\/code>&nbsp;is one of:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Protocol<\/th><th>Description<\/th><\/tr><tr><td><code>file<\/code><\/td><td>a file on your local system<\/td><\/tr><tr><td><code>ftp<\/code><\/td><td>a file on an anonymous FTP server<\/td><\/tr><tr><td><code>http<\/code><\/td><td>a file on a World Wide Web server<\/td><\/tr><tr><td><code>gopher<\/code><\/td><td>a file on a Gopher server<\/td><\/tr><tr><td><code>WAIS<\/code><\/td><td>a file on a WAIS server<\/td><\/tr><tr><td><code>news<\/code><\/td><td>a Usenet newsgroup<\/td><\/tr><tr><td><code>telnet<\/code><\/td><td>a connection to a Telnet-based service<\/td><\/tr><tr><td>etc.<\/td><td>other, often application-specific, protocols<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>You can also use a&nbsp;<code>mailto<\/code>&nbsp;protocol:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><a href=\"https:\/\/mail.google.com\/mail\/?view=cm&amp;fs=1&amp;tf=1&amp;to=president@whitehouse.gov\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>mailto:president@whitehouse.gov<\/strong><\/a><\/pre>\n\n\n\n<p>The&nbsp;<code>:port<\/code>&nbsp;is generally omitted, because each protocol has its own default port number.&nbsp; However, it is sometimes required when a server is using an non-standard port number.<\/p>\n\n\n\n<p>Here&#8217;s a typical example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><a href=\"http:\/\/www.ncsa.uiuc.edu\/General\/Internet\/WWW\/HTMLPrimer.html\"><strong>http:\/\/www.ncsa.uiuc.edu\/General\/Internet\/WWW\/HTMLPrimer.html<\/strong><\/a><\/pre>\n\n\n\n<p>Another form of URL is a&nbsp;<em>relative URL<\/em>. For example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>data\/planets.dat<\/strong><\/pre>\n\n\n\n<p>which is relative to some other URL.<\/p>\n\n\n\n<p>For more information about URLs, see:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><a href=\"http:\/\/www.ncsa.uiuc.edu\/demoweb\/url-primer.html\"><strong>http:\/\/www.ncsa.uiuc.edu\/demoweb\/url-primer.html<\/strong><\/a><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"The_Java_URL_Class\"><\/span>The Java URL Class<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Java&#8217;s&nbsp;<code><strong>java.net.URL<\/strong><\/code>&nbsp;class encapsulates <em>URLs<\/em>. It has constructors:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>URL(String absURL)\nURL(URL baseURL, String relURL)\nURL(String protocol, String host, String file)\nURL(String protocol, String host, int port, String file)<\/strong><\/pre>\n\n\n\n<p>Each of these constructors throws a&nbsp;<code><strong>MalformedURLException<\/strong><\/code>&nbsp;if the syntax for the resulting URL is incorrect. You must write code that is prepared for this exception:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>try\n{\n    String url = \"http:\/\/java.sun.com\";\n    URL u = new URL(url);\n    \/\/ ...\n}\ncatch (MalformedURLException e)\n{\n    \/\/ Deal with the exception...\n}<\/strong><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"getDocumentBase_and_getCodeBase\"><\/span>getDocumentBase() and getCodeBase()<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>These methods of the&nbsp;<code><strong>javax.swing.JApplet<\/strong><\/code>&nbsp;(and&nbsp;<code><strong>java.applet.Applet<\/strong><\/code>) class return the following:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Method<\/th><th>Description<\/th><\/tr><tr><td><code>getDocumentBase()<\/code><\/td><td>returns the URL of the HTML file that contains the applet<\/td><\/tr><tr><td><code>getCodeBase()<\/code><\/td><td>returns the URL of the applet<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"getImage_and_getAudioClip\"><\/span>getImage() and getAudioClip()<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>These methods of the&nbsp;<code><strong>javax.swing.JApplet<\/strong><\/code>&nbsp;(and&nbsp;<code><strong>java.applet.Applet<\/strong><\/code>) class return the specified image and audio clip, respectively.&nbsp;<\/p>\n\n\n\n<p>For example:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\npackage applets;\n\nimport java.applet.Applet;\nimport java.applet.AudioClip;\n\nimport java.awt.BorderLayout;\nimport java.awt.Color;\n\nimport java.net.MalformedURLException;\nimport java.net.URL;\n\nimport javax.swing.JApplet;\nimport javax.swing.JLabel;\n\nimport multimedia.ImagePanel;\n\npublic class MultimediaApplet extends JApplet\n{\n  public void init()\n  {\n    \/\/ First, create the image part of the GUI\n    URL&#x5B;] imageURLs = gatherImageURLs();\n    getContentPane().add(new ImagePanel(imageURLs),\n                         BorderLayout.CENTER);\n    \n    \/\/ Next, a label indicating the state of the audio part\n    m_soundLabel = new JLabel(&quot;Loading audio clip...&quot;);\n    m_soundLabel.setOpaque(true);\n    m_soundLabel.setBackground(Color.WHITE);\n    getContentPane().add(m_soundLabel, BorderLayout.SOUTH);\n    \n    \/\/ Load the audio clip\n    loadAudioClip(&quot;audio\/yahoo1.au&quot;);\n    \n    if (m_sound == null)\n    {\n      m_soundLabel.setText(&quot;No audio clip found...&quot;);\n      m_soundLabel.setForeground(Color.RED);\n    }\n    else\n    {\n      m_soundLabel.setText(&quot;Playing audio clip...&quot;);\n    }\n  }\n  \n  public void start()\n  {\n    if (m_sound == null)\n    {\n      System.err.println(&quot;No audio clip to play!&quot;);\n    }\n    else\n    {\n      m_sound.play();\n    }\n  }\n  \n  private URL&#x5B;] gatherImageURLs()\n  {\n    URL&#x5B;] imageURLs = new URL&#x5B;2];\n    \n    \/\/ Get the URL of applet\n    URL baseURL = getCodeBase();\n    System.out.println(&quot;CodeBase: &quot; + baseURL);\n    \n    \/\/ Now get the URL for the first image file, below that directory\n    URL imageURL = null;\n    try\n    {\n      imageURL = new URL(baseURL, &quot;images\/bleye.gif&quot;);\n      \n      \/\/ Set in the first image URL.\n      imageURLs&#x5B;0] = imageURL;\n      \n      \/\/ The second image is on the web\n      imageURLs&#x5B;1] = new URL(\n          &quot;http:\/\/www.rivier.edu\/faculty\/bhiggs\/web\/cs585aweb\/images\/monalisa.jpg&quot;);\n    }\n    catch (MalformedURLException mue)\n    {\n      \/\/ Something wrong with our URL handling\n      mue.printStackTrace();\n    }\n    \n    return imageURLs;\n  }\n  \n  private void loadAudioClip(String path)\n  {\n    AudioClip clip = null;\n    URL baseURL = getCodeBase();\n    System.out.println(&quot;Audio clip baseURL: &quot; + baseURL);\n    URL audioClipURL = null;\n    try\n    {\n      audioClipURL = new URL(baseURL, path);\n      System.out.println(&quot;Audio clip URL: &quot; + audioClipURL);\n      clip = Applet.newAudioClip(audioClipURL);\n    }\n    catch (MalformedURLException mue)\n    {\n      mue.printStackTrace();\n    }\n    m_sound = clip;\n    System.out.println(&quot;Audio clip loaded.&quot;);\n  }\n  \n  \/\/\/\/\/\/\/\/\/ Data \/\/\/\/\/\/\/\/\/\/\/\/\/\/\n  private JLabel m_soundLabel;\n  private AudioClip m_sound = null;\n}\n\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\npackage multimedia;\n\nimport java.awt.BorderLayout;\nimport java.awt.Color;\nimport java.awt.Graphics;\n\nimport java.net.URL;\n\nimport javax.swing.ImageIcon;\nimport javax.swing.JLabel;\nimport javax.swing.JPanel;\nimport javax.swing.SwingUtilities;\n\npublic class ImagePanel extends JPanel\n{\n  public ImagePanel(final URL&#x5B;] imageURLs)\n  {\n    setBackground(Color.WHITE);\n    setLayout(new BorderLayout());\n    \n    \/\/ Indicate that we&#039;re loading images,\n    \/\/ which may take a long time.\n    JLabel statusLabel = new JLabel(&quot;Loading Images...&quot;,\n        JLabel.CENTER);\n    statusLabel.setForeground(Color.BLACK);\n    add(statusLabel, BorderLayout.CENTER);\n    \n    \/\/ Load the images in a separate thread to avoid\n    \/\/ hanging up this thread waiting for load completion.\n    Thread loader = new Thread()\n    {\n      public void run()\n      {\n        loadImages(imageURLs);\n        \/\/ When done, cause a repaint from the \n        \/\/ event dispatcher thread\n        SwingUtilities.invokeLater( new Runnable()\n        {\n          public void run()\n          {\n            \/\/ Remove the &quot;Loading images...&quot; label\n            ImagePanel.this.removeAll();\n            \/\/ and cause the images to display\n            ImagePanel.this.repaint();\n          }\n        }\n        );\n      }\n    };\n    \/\/ Start the loader thread\n    loader.start();\n  }\n  \n  public void paintComponent(Graphics g)\n  {\n    super.paintComponent(g);\n    \n    if (m_imagesLoaded)\n    {\n      g.setColor(Color.BLACK);\n      int x = 5;\n      int y = 5;\n      for (int i = 0; i &lt; m_image.length; i++)\n      {\n        if (m_image&#x5B;i] != null)\n        {\n          m_image&#x5B;i].paintIcon(this, g, x, y);\n          x += m_image&#x5B;i].getImage().getWidth(this) + 5;\n        }\n        else\n        {\n          g.setColor(Color.RED);\n          g.drawString(&quot;No image found&quot;, x, y);\n        }\n      }\n    }\n  }\n  \n  private void loadImages(URL&#x5B;] imageURLs)\n  {\n    m_image = new ImageIcon&#x5B;imageURLs.length];\n    for (int i = 0; i &lt; imageURLs.length; i++)\n    {\n      m_image&#x5B;i] = new ImageIcon(imageURLs&#x5B;i]);\n    }\n    m_imagesLoaded = true;\n  }\n  \n  \/\/\/\/ Private data \/\/\/\/\/\n  private ImageIcon&#x5B;] m_image;\n  private boolean m_imagesLoaded;\n}\n\n<\/pre><\/div>\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Again, I can&#8217;t show you the result because Java applets have been deprecated and removed from Java<\/p><\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Applet_Context\"><\/span>Applet Context<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>An applet runs inside a browser or applet viewer.<\/p>\n\n\n\n<p>An applet running within a browser can ask the browser to do things for it:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Fetch an audio clip<\/li><li>Show a short message in the status line<\/li><li>Show a different web page<\/li><\/ul>\n\n\n\n<p>The browser can perform these requests or ignore them.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>To communicate with the browser, an applet calls the <code><strong>java.applet.Applet.getAppletContext()<\/strong><\/code> method, which returns an object that implements an interface of type <strong><code>java.applet.AppletContext<\/code>.<\/strong><\/li><li>Think of&nbsp;<code><strong>AppletContext<\/strong><\/code>&nbsp;as a communication path between the applet and the browser.<\/li><li><code><strong>AppletContext<\/strong><\/code>&nbsp;provides the following methods:<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Method<\/th><th>Description<\/th><\/tr><tr><td><code>void showStatus(String message)<\/code><\/td><td>Shows the message in the status line of the browser<\/td><\/tr><tr><td><code>Enumeration getApplets()<\/code><\/td><td>Returns an enumeration of all the applets in the same context (same web page)<\/td><\/tr><tr><td><code>Applet getApplet(String name)<\/code><\/td><td>Returns the applet in the current context with the specified name (null if none exists)<\/td><\/tr><tr><td><code>void showDocument(URL url)<\/code><\/td><td>Shows a new web page in the browser, displacing the current page.<\/td><\/tr><tr><td><code>void showDocument(URL url, String target)<\/code><\/td><td>Shows a new web page in the browser, specifying the target frame<br>(&#8220;_self&#8221;, &#8220;_parent&#8221;, &#8220;_top&#8221;, &#8220;_blank&#8221;, or &lt;frame-name&gt;)<\/td><\/tr><tr><td><code>Image getImage(URL url)<\/code><\/td><td>Returns an image object that encapsulates the image specified by the URL<\/td><\/tr><tr><td><code>AudioClip getAudioClip(URL url)<\/code><\/td><td>Returns an AudioClip object that encapsulates the sound file specified by the URL.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Converting_Applications_to_Applets\"><\/span>Converting Applications to Applets<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>A Java program can be&nbsp;<em><strong>both<\/strong><\/em>&nbsp;an applet and an application:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\n\/\/ ...\npublic class AppletApplication extends JApplet\n{\n    public void init() \n    { ... }\n    \n    \/\/ ...\n    \n    public static void main(String&#x5B;] args) \n    { ... }\n}\n<\/pre><\/div>\n\n\n<p>To make it work, the main method must create a frame for the applet to execute in.<\/p>\n\n\n\n<p>It&#8217;s convenient to create a frame to use for this purpose:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\n\/\/ ...\npublic class AppletFrame extends JFrame\n{\n    public AppletFrame(JApplet applet, int width, int height)\n    {\n        setTitle(applet.getClass.getName());\n        setSize(width, height);\n        setDefaultCloseOperation(EXIT_ON_CLOSE);\n\n        JPanel panel = new JPanel( new BorderLayout() );\n        getContentPane().add(panel);\n\n        panel.add(applet, BorderLayout.CENTER); \/\/ Add applet to frame\n\n        applet.init();\t\t\/\/ Init the applet\n        setVisible(true);\n        applet.start();\t\t\/\/ Start the applet\n    }\n\n    \/\/ ...\n}\n<\/pre><\/div>\n\n\n<p>So the main method of the&nbsp;<code><strong>AppletApplication<\/strong><\/code>&nbsp;should do the following:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\n\/\/ ...\npublic class AppletApplication extends JApplet\n{\n    public void init() \n    { ... }\n    \n    \/\/ ...\n    \n    public static void main(String&#x5B;] args) \n    {\n        new AppletFrame(new AppletApplication(), 620, 400);\n    }\n}\n<\/pre><\/div>\n\n\n<p>Unfortunately, this is not sufficient. If the applet tries to execute code like:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>getAppletContext()<\/strong><\/pre>\n\n\n\n<p>because there is no applet context in the&nbsp;<code><strong>AppletFrame<\/strong><\/code>.The fix is to implement two interfaces in&nbsp;<code><strong>AppletFrame<\/strong><\/code>:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>AppletStub<\/code><\/li><li><code>AppletContext<\/code><\/li><\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\n\/\/ ...\npublic class AppletFrame extends JFrame\n\timplements AppletStub, AppletContext\n{\n    \/\/ AppletStub methods\n    public boolean isActive() { return true; }\n    public URL getDocumentBase() { return null; }\n    public URL getCodeBase() { return null; }\n    public String getParameter(String name) { return &quot;&quot;; }\n    public AppletContext getAppletContext() { return this; }\n    public void appletResize(int width, int height) {}\n\n    \/\/ AppletContext methods\n    public AudioClip getAudioClip(URL url) { return null; }\n    public Image getImage(URL url) { return null; }\n    public Applet getApplet(String name) { return null; }\n    public Enumeration getApplets() { return null; }\n    public void showDocument(URL url) {}\n    public void showDocument(URL url, String target) {}\n    public void showStatus(String status) {}\n\n    public AppletFrame(Applet applet, int width, int height)\n    {\n        setTitle(applet.getClass.getName());\n        setSize(width, height);\n        setDefaultCloseOperation(EXIT_ON_CLOSE);\n\n        JPanel panel = new JPanel( new BorderLayout() );\n        getContentPane().add(panel);\n\n        panel.add(applet, BorderLayout.CENTER); \/\/ Add applet to frame\n\n        applet.setStub(this);\t\/\/ Set up the AppletStub\n        applet.init();\t\t\/\/ Init the applet\n        setVisible(true);\n        applet.start();\t\t\/\/ Start the applet\n    }\n\n    \/\/ ...\n}\n<\/pre><\/div>\n\n\n<p>Another possibility is to use inheritance to allow any applet to be executable as an application:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\npublic class CalculatorAppletApplication\n\t\textends AppletApplication\n{\n    public static void main(String&#x5B;] args)\n    {\n        new AppletFrame(new CalculatorApplet(), 150, 100);\n    }\n}\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>NOTE: Java applets have been\u00a0deprecated\u00a0since Java 9 in 2017, and were removed from Java SE (Standard Edition) 11 (18.9), released in September 2018.This means that, while you may find learning about Java applets to be interesting, it won&#8217;t get you far today in practical web applications using Java. There are various alternatives, but most of [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":34,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_eb_attr":"","_uag_custom_page_level_css":"","ocean_post_layout":"left-sidebar","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"ocs-course-topics-sidebar","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"0","ocean_custom_header_template":"0","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","footnotes":""},"class_list":["post-73","page","type-page","status-publish","hentry","entry"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"ocean-thumb-m":false,"ocean-thumb-ml":false,"ocean-thumb-l":false},"uagb_author_info":{"display_name":"Bryan Higgs","author_link":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/author\/bryan\/"},"uagb_comment_info":0,"uagb_excerpt":"NOTE: Java applets have been\u00a0deprecated\u00a0since Java 9 in 2017, and were removed from Java SE (Standard Edition) 11 (18.9), released in September 2018. This means that, while you may find learning about Java applets to be interesting, it won&#8217;t get you far today in practical web applications using Java. There are various alternatives, but most&hellip;","_links":{"self":[{"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/pages\/73","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/comments?post=73"}],"version-history":[{"count":11,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/pages\/73\/revisions"}],"predecessor-version":[{"id":1249,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/pages\/73\/revisions\/1249"}],"up":[{"embeddable":true,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/pages\/34"}],"wp:attachment":[{"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/media?parent=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}