SmoothScroll Applet

[You need a java-enabled browser for this to work.]
Modify the applet's scrolling text via JavaScript:

Here are some links to the files used for this demonstration:

SmoothScroll.class
SmoothScroll.jar
hare.gif
tortoise.gif
smoothscrolldemo.txt
colors.txt
Buffy98.au
SmoothScroll.zip

Shift-Click the above links to download the files.
SmoothScroll is a text scroller and much more. In addition to scrolling text in a variety of fonts and colors, it can play sounds, scroll images, generate a stationary headline, display stationary images, scroll the stationary image in any of four (4) directions, and respond to javascript methods.

Applet Parameters:


FGTextFontName:   "Courier", "Helvetica", or "TimesRoman".  This is the font that will
                  be displayed as a headline (foreground text) if you choose to use one.

FGTextFontStyle:  "bold", "italic", "bolditalic", or "plain"

FGTextFontSize:   An integer between 1-127 for the point size of the foreground text.

FGTextFontColor:  A 6 digit hex string or one of about 140 recognized color names,
                  such as "crimson", "dodgerblue", "hotpink", "orangered", or "goldenrod-yellow",
                  just to name a few.  A 6 digit hex string follows the form of RRGGBB, for 
                  example the string "ff0000" would be the color red, "7f7f7f" gray, etc.

FGTextBGColor:    The background color of the foreground text headline, if any.

FileName:         The name of the file containing the text to scroll, default is "scrolltext.txt".

ShowSplashScreen: Boolean value, "1" = true, "0" = false, default is true.  To suppress
                  the splash screen, you will need to implement the "Author" and "Origin"
                  parameters described below.

ShowBorder:       Boolean value, "1" = true, "0" = false, default is false.

BorderColor:      Color of the border, if any, default is black.

AutoRefresh:      Boolean value, "1" = true, "0" = false, default is false.  If true, the
                  applet will automatically reload the .txt file each time it has scrolled
                  through to the end.  Useful if your .txt file is being constantly updated.
                  For example, if your server is constantly updating the information in the
                  .txt file, such as news headlines, stock prices, etc., you could set
                  this value to true.  It is better to leave it false otherwise, since
                  there is a performance penalty for reloading the file each time.

Author:           Set this to "Mark Ganson" if you wish to suppress the splash screen
                  or if you wish to have dynamic hyperlinks in your .txt file.  Otherwise,
                  anyone clicking the applet will be hyperlinked to my java4free website.

Origin:           Set this to "http://www.bigfoot.com/~java4free" for the reasons given for
                  the "Author" parameter above.

LinkTarget:       If you wish to target your hyperlinks to a particular frame, set this
                  parameter to the name of the frame.  Can also be "_top", "_self",
                  "_parent", or "_blank" (default: "_blank")  This is a global variable
                  used by all hyperlink forms, i.e. fgimagelink, fgtextlink, and link.	

BGColor:          A background color for the scrolling text.  (default: white)

HighLightColor:   Color used for a neat feature which simulates using a yellow
                  highlight marker to emphasize specific text. (default: yellow)

added in version 1.03:
DisableLinks:     Set this to "1" or "true" to disable the mouse handlers, such as
                  when the user clicks on the applet or when the user moves the mouse over the
                  applet.  This parameter is false by default.  (Requires usage of the Author
                  and Origin parameters.)

Inline Format Tags:


SmoothScroll supports a veritable plethora (a bunch) of inline format tags, which are inserted into the text file containing the scrolling text. These format tags are similar to HTML tags in many instances, and so, should be familiar with most webmasters already.

The following is a comprehensive list of the supported inline format tags:

<b>         Turns on the bold font.

</b>        Turns off the bold font.

<u>         Turns on underscore font.

</u>        Turns off underscore font.

<s>         Turns on the strikethrough font.

</s>        Turns off the strikethrough font.

<h>         Turns on the highlighted font.  (See "HighLightColor" parameter)

</h>        Turns off the hightlighted font.

<i>         Turns on the italic font.

</i>        Turns off the italic font.

<courier>   Turns on the "Courier" font.

<helvetica> Turns on the "Helvetica" font.

<timesroman>Turns on the "TimesRoman" font.

<size=N>    "N" is an integer between 1 and 127 representing the font point size.

<color=N>   "N" is a color, either in 6 digit hex format or one of about
            140 recognized string literals, example: "aquamarine", "lavender",
            "olivedrab", "midnightblue", or "00ff00" (green)  This tag will
            set the current scrolling text font color.

<hcolor=N>  "N" is the color of the highlight marker.  Similar to the
            "HighLightColor" applet parameter in its effect.

<bcolor=N>  "N" is the color of the border, if any. (See "ShowBorder" parameter)

<image=N>   "N" is the name of an image that will be scrolled along with the
            scrolling text.  Images can be either .jpg or .gif.  Transparent
            and (not tested) presumably animated .gifs are supported.

<fgimage=N> "N" is the name of a foreground stationary image that will not be
            scrolled along with the scrolling text.  Scrolling text will appear
            to scroll underneath the foreground image.  Note that while the
            fgimage is stationary by default, it can be scrolled in any of four
            directions (up, down, left, or right) via other inline tags described
            below.  By default, the fgimage will be placed at x,y coordinates
            0, 0 (upper left), but can also be positioned via other inline tags
            which will be described below.  Use <fgimage=null> to remove.

<fgimagelink=N>"N" is the url to use as a hyperlink when the user clicks on
            the fgimage.  If the fgimage is an advertizing banner, you would put the
            a href= html stuff here.  (default: "null")  If this value is "null", the
            applet will handler the click as if it were clicked outside the image area.

<fgimagestatus=N>"N" is the status message to display in the browser's
            status bar when the user moves his mouse over the fgimage.  (default: null)
            Note that if the status is "null", the general status message for mouseover
            events for the applet as a whole will be displayed.  Also, unless the
            fgimagelink is other than "null", the fgimagestatus value will be treated
            as though it were "null", too. 

<fgimagescrollleft=N>"N" is an integer telling the applet the number of times
            to scroll the fgimage to the left.

<fgimagescrollup=N>"N" is an integer telling the applet the number of times to
            scroll the fgimage up.

<fgimagescrolldown=N>"N" is an integer telling the applet the number of times to
            scroll the fgimage down.

<fgimagescrollright=N>"N" is an integer telling the applet the number of times to
            scroll the fgimage to the right.

<fgimagescrollincrement=N>"N" is an integer telling the applet the number of
            pixels to scroll the applet each time when using one of the 
            <fgimagescrolldirection=N> tags.  (default is to move 1 pixel per scroll)

<fgimageposx=N>"N" is the new x coordinate to place the fgimage at.

<fgimageposy=N>"N" is the new y coordinate to place the fgimage at.

<speed=N>   "N" is the scroll delay (in milliseconds) between animation frames.
            The lower this value, the faster the scrolling. (default: 1)

<pause=N>   "N" is the number of milliseconds to pause the scrolling text.  For
            example, <pause=5000> would pause the scrolling for 5 seconds.

<fgtext=N>  "N" is the text to use for a foreground text (fgtext) object.  This
            is actually a dynamically-generated in memory image that will be
            displayed along the top of the applet.  The applet will use the font that
            was specified with the "FGFontTextxxx" applet parameters described above.
            Unlike the fgimage objects, the fgtext objects cannot be moved, except
            that they can be removed or modified dynamically via this tag.
            Use <fgtext=null> to remove the object from the screen.

<fgtextlink=N>"N" is the url to use as a hyperlink when the user clicks
            the foreground text object.  (default is "null")  If this value is "null"
            the applet will handle the click as though it were outside the fgtext area.

<fgtextstatus=N>"N" is the status message to display in the browser&g#39s status
            bar area when the user moves his mouse over the foreground text.  Note that
            this value will have no effect if the fgtestlink value is not set.

<play=N>    "N" is the name of a Sun .au sound file.  The format of
            this file must be 16-bit, 8,000 hz, gLaw, Mono.  NO OTHER FORMAT WORKS.
            The simplest (and least expensive) way to create the .au files is to convert
            them over from other formats, such as .wav with a freeware utility called SOX.  
            You can download it here.
            Microsoft Windows and several other platforms are supported.  If you are
            using Windows, from the command prompt, switch to the folder containing
            the sox.exe file and enter  sox whatever.wav -r8000 -ul whatever.au,
            assuming that whatever.wav is the .wav file you wish to convert to whatever.au.
            This also assumes that whatever.wav is located in the same folder as the 
            sox.exe file.

<stop=N>    "N" is the name of a Sun .au sound file.  This tag will cause
            the applet to stop playing or looping a sound file.

<loop=N>    "N" is the name of a Sun .au sound file.  This tag will cause
            the applet to repeatedly play a sound file over and over again until a
            <stop=N> tag is found.

<link=N>    "N" is a URL that the surfer will be hyperlinked to when the
            surfer clicks on the applet with the mouse.  Example, use
            "<link=http://www.myserver.com/myfolder/mydocument.html>

<status=N>  "N" is a status bar message that will be displayed in the browser's
            status bar area when the mouse moves over the applet.
            Typically, this would be used in conjunction with the
            <link=N> tag to invite the user to click for the hyperlink.

<target=N>  "N" represents a targeted frame name.  Identical to the applet
            parameter "LinkTarget".  You would use this inline tag where
            you wanted to target different frames with each hyperlink.
            The default is "_blank", which opens the link in a new window.

<!N>        "N" is a comment and will be completely ignored by the applet.
            You would typically use this feature to comment to yourself or
            other human readers what you are trying to accomplish with
            some of the inline tags or anything else you would want to
            tell someone who is reading your .txt file that you would
            not want to have as part of the scrolling message.  It is also most
            useful as a way to temporarily remove a particular tag and yet leave
            the tag text there so that it can be easily added back in at a later time.

<<N>        "N" is a pseudo tag, which will be displayed literally
            in the scrolling text rather than actually implemented.
            For example, <<image=mypic.jpg> would display
            <image=mypic.jpg> rather than an image named mypic.jpg.

<spawn=N>    "N" is a fully-qualified URL to an object file to be spawned
            by the browser.  This is just as if the spawn= argument was
            a link= argument and the user clicked on the applet with the mouse.
            This is useful where you wish to spawn the registered application
            to play a particular type of media file, for example.  You would
            use <spawn=http://www.myserver.com/myfolder/mysong.mid> to
            spawn the default media player to play the midi file "mysong.mid".
            The spawn argument can be practically any file type, including
            .html files.  Note that spawning must be enabled for this to
            work.  You can enable/disable spawning with the <enablespawning>
            tag described below.  This requires a fully-qualified URL, rather
            than a relative URL.  That is, <spawn=http://www.myserver.com/mysong.mid>
            will spawn the appropriate media player program for midi files, but
            <spawn=mysong.mid> will not work.

<enablespawning=N> "N" is a boolean value, "1" = true, "0" = false.
            If true, spawning is enabled.  If false, spawning is disabled.
            This is to be used when you don't want to repeatedly spawn an
            object over and over again each time the applet scrolls through
            the .txt file.  You would typically spawn an object file and then
            disable spawning so that the object file would not be spawned
            again on the next pass.  For example, you could use
            <spawn=http://www.myserver.com/ramfiles/rocknroll.ram>
            to spawn the realaudio player program (or whatever the
            registered media program is installed on the user's machine)
            to play the streaming "rocknroll.ram" file.  Then, use
            <enablespawning=0> to disable spawning so that the
            applet doesn't try to respawn the same .ram file the next
            time it is encountered on the next re-scroll of the .txt file.

JavaScript public Interface:

You can communicate with SmoothScroll via JavaScript by using the following publicly
accessible methods:

public void start();
Tells the applet to restart scrolling after being stopped previously with a call to 
public void stop();

public void stop();
Tells the applet to stop scrolling.  Restart with a call to public void start();

public void appendText(String strText);
Appends the text in the string 'strText' to the internal memory buffer that has
been reserved for holding an in-memory .txt file.  Use multiple calls to this
method to dynamically build your own .txt file from within JavaScript, then call
public void go(); to initialize the applet.  Note that the "FileName" applet
parameter must be set to "javascript" in order for this to work.  Alternatively,
you can call public void setFileName('javascript'); to set the applet to memory
mode rather than file mode.  Line feeds are sent with the '\n' character.

public void setText(String strText);
Sets the text in internal memory buffer that has been reserved for holding an
in-memory .txt file to the text contained in the string 'strText'.  Identical
in functionality to public void appendText(String strText);, except that the
value in strText replaces whatever was value was already in the buffer with
the value in strText whereas public void appendText(String strText); will
concatenate (append to the end) the value in strText to the contents in the memory buffer.
Line feeds are sent with the '\n' character.  Set strText to an empty string to
clear the in-memory file contents.

public void go();
Informs the applet that you are finished building your in-memory text file with
calls to public void setText(String strText); and/or public void appendText(String strText);
If the applet sees that the FileName parameter has been set to "javascript", it will
block until it receives notification that the in-memory text file has been completely
built.  It will then "read" the file just as though it were a text file located on the
server.  Note that if you want to re-build the in-memory text file after making the
initial call to public void go();, you will need to make a call to 
public void setFileName(String strFileName);, modify the in-memory text file, and then
make a subsequent call to public void go(); to re-initialize the applet.

public void setFileName(String strFileName);
Use this to re-initialize the applet with a new file.  Use "javascript" as the name
of the file if you want an in-memory text file that you can create on-the-fly from
JavaScript code.

public void setScrollSpeed(String strNewSpeed);
The parameter strNewSpeed is a string that will be interpreted as a number by the applet.
This interpreted number is the amount of milliseconds to pause in between animation
frames.  More precisely, this is the minimum number of milliseconds to pause in between
frames.  Depending on the size of the text file and whether there are foreground images
(fgimage) and/or foreground text (fgtext) objects.  Of course, the speed of the client
computer system will also have an impact on this.  Generally speaking, the larger the
text file, the slower the applet will be able to scroll at its highest speed (0).  Bear
in mind, however, that a speed of 0 might be fine on your slower test computer, but might
be far too fast on a newer computer since a speed of 0 means to not pause at all in between
animation frames.  The default is a 1 millisecond (.001 seconds) delay in between frames.

public String getMemoryBuffer();
Get the internal memory buffer containing the file text.  This is only valid after the
applet has completed the process of loading a .txt file from the server.  This is useful
where you wish to dynamically append data to the end of a file that was loaded over the
network.

public void setBGColor(String strColor);
Set the color of the applet's background to the string strColor.  Note that due to the
way SmoothScroll pre-builds the scrolling text during the initialization process, it is
necessary to re-initialize the applet in order for this method to work.  Thus, each call
to public void setBGColor(String strColor); results in re-initializing the applet.  If
you are looking to flash the background color to get attention, for example, this
method does not provide a useful mechanism for this.  You could, however, create a number
of solid color .gif or .jpg files the same size as the applet and then flip through these
with  inline tags.  Because foreground images are pre-loaded during the
initialization phase, this should not be too much of a performance penalty.

public String colorName2HexString(String strColorName);
Pass in a color string literal, such as "blue" and receive the hex string equivalent.  For
example, strMyColor = document.colorName2HexString('red'); would put the value "ff0000"
into the strMyColor javascript var.  This form uses this method to return a translated
hex string based on the color literal typed in by the user or "unknown color value" in
case of an unrecognized literal.

Simple Color Literal to Hex String Translator
Color Literal String: Equivalent Hex Value:

More on Colors:

SmoothScroll provides a number of mechanisms for setting colors. Each of these mechanisms use the same internal methods to convert the color parameter to a color variable that the applet can understand. The applet expects either a string literal color name, such as common variety basic colors "red", "blue", "green", "orange", "purple", etc., and also supports about 140 less common colors, like "salmon", "sienna", "saddlebrown", and "steelblue", to name a few. If the color isn't recognized by the applet, it will either mark it as an error if it is an inline tag or default to a reasonable default color. If the color you chose is not recognized by the applet, you can use 6-digit hex strings in the form of rrggbb, where rr is the red component, gg is the green component, and bb is the blue component. Each color component can range from a low of 00 to a high of ff, with 00 being darker and ff being lighter. Enter a color literal into the form above and hit the Convert2Hex button to see some examples of hex string values. Click here to have the applet display a scrolling list of all currently supported colors. These I have inserted into a file named "colors.txt".

Click here to see SmoothScroll as a scrolling content provider, where it is used to display a scrolling list of hyperlinked, webmaster-related headlines.