A More Fully Scripted Clock : Applet Jar « Development « JavaScript DHTML






A More Fully Scripted Clock

/*
JavaScript Bible, Fourth Edition
by Danny Goodman 

John Wiley & Sons CopyRight 2001
*/

<HTML>
<HEAD>
<TITLE>Clock with Lots o' Widgets</TITLE>
<SCRIPT LANGUAGE="JavaScript1.1">

function setTimeZone(popup) {
    var choice = popup.options[popup.selectedIndex].value
    document.clock2.setTimeZone(choice)
}

function setColor(form) {
    var bg = form.backgroundColor.options[form.backgroundColor.selectedIndex].value
    var fg = form.foregroundColor.options[form.foregroundColor.selectedIndex].value
    document.clock2.setColor(bg, fg)
}

function setFont(form) {
    var fontName = form.theFont.options[form.theFont.selectedIndex].value
    var fontStyle = form.theStyle.options[form.theStyle.selectedIndex].value
    var fontSize = form.theSize.options[form.theSize.selectedIndex].value
    document.clock2.setFont(fontName, fontStyle, fontSize)
}
function getAppletInfo(form) {
    form.details.value = document.clock2.getInfo()
}

function showSource() {
    var newWindow = window.open("ScriptableClock.java","", 
    "WIDTH=450,HEIGHT=300,RESIZABLE,SCROLLBARS")
}

</SCRIPT>
</HEAD>
<BODY>
<APPLET CODE="ScriptableClock.class" NAME="clock2" WIDTH=500 HEIGHT=45>
<PARAM NAME=bgColor VALUE="Black">
<PARAM NAME=fgColor VALUE="Red">
</APPLET>

<P>
<FORM NAME="widgets2">
Select Time Zone:
<SELECT NAME="zone" onChange="setTimeZone(this)">
    <OPTION SELECTED VALUE="Locale">Local Time
    <OPTION VALUE="GMT">Greenwich Mean Time
</SELECT><P>
Select Background Color:
<SELECT NAME="backgroundColor" onChange="setColor(this.form)">
    <OPTION VALUE="White">White
    <OPTION SELECTED VALUE="Black">Black
    <OPTION VALUE="Red">Red
    <OPTION VALUE="Green">Green
    <OPTION VALUE="Blue">Blue
    <OPTION VALUE="Yellow">Yellow
</SELECT>
Select Color Text Color:
<SELECT NAME="foregroundColor" onChange="setColor(this.form)">
    <OPTION VALUE="White">White
    <OPTION VALUE="Black">Black
    <OPTION SELECTED VALUE="Red">Red
    <OPTION VALUE="Green">Green
    <OPTION VALUE="Blue">Blue
    <OPTION VALUE="Yellow">Yellow
</SELECT><P>
Select Font:
<SELECT NAME="theFont" onChange="setFont(this.form)">
    <OPTION SELECTED VALUE="TimesRoman">Times Roman
    <OPTION VALUE="Helvetica">Helvetica
    <OPTION VALUE="Courier">Courier
    <OPTION VALUE="Arial">Arial
</SELECT><BR>
Select Font Style:
<SELECT NAME="theStyle" onChange="setFont(this.form)">
    <OPTION SELECTED VALUE="Plain">Plain
    <OPTION VALUE="Bold">Bold
    <OPTION VALUE="Italic">Italic
</SELECT><BR>
Select Font Size:
<SELECT NAME="theSize" onChange="setFont(this.form)">
    <OPTION VALUE="12">12
    <OPTION VALUE="18">18
    <OPTION SELECTED VALUE="24">24
    <OPTION VALUE="30">30
</SELECT><P>
<HR>
<INPUT TYPE="button" NAME="getInfo" VALUE="Applet Info..." onClick="getAppletInfo(this.form)">
<P>
<TEXTAREA NAME="details" ROWS=11 COLS=70></TEXTAREA>
</FORM>
<HR>
</BODY>
</HTML>


           
       








Related examples in the same category

1.Calling Java Methods
2.Accessing Applets from within JavaScript
3.Using JavaScript in an Applet
4. Stopping and Starting an Applet
5.Basic Signed Script Structure