Saturday, 29 November 2008

The Applet Call

And now, the tiny scrap of HTML that calls the Bridge Applet and handles the buttons.

The first thing the code does is to start the timeout for checking the applet. Once called, this function continuously calls itself again. I fancy that we are sometimes calling an applet that isn't loaded yet. This causes a confusing message from time to time and I should catch and suppress it (using the self.onerror function that is the first line of Javascript) but while in development, I just let the error show. I hoped there ought to be a cleaner method of starting it off, though it's hard for Java to report to its calling function.

Next, we set up a table with the applet load instruction on the left and the buttons on the right.

All the buttons call the applet, either via the javascript functions we talked about yesterday, or directly.

<BODY onLoad = "setTimeout('checkApplet()', 5000);">
<APPLET code="Bridge" archive = "com/bridge/bridge11.jar"
width = "640" height="480" id="Bridge"
name="Bridge"> </APPLET></TD>
<FORM name = form1>
<input type="button" value="Inventory"
onClick = "document.Bridge.goInv()"><BR>
<input type="button" value="Save"
onClick = "saveGame()"><BR>
<input type="button" value="Restore"
onClick = "restoreGame()"><BR>
<input type="button" value="Switch Music Off"
onClick = "togglesound()" name="togglebutton">

No comments: