ModernJava
http://www.modernminds.com
T extured Button Bar

This example of the TextURLButtonBar applet demonstrates the use of a small GIF or JPEG file as a button bar texture.

Notice that it is possible to position buttons on the button bar. In this example, the buttons are divided into two groups of two buttons.

Try moving your mouse over the buttons and clicking on the buttons (clicking on the buttons will not cause a URL to load in this example). Notice that the text in the browser's status bar changes as the mouse is moved over each button. Also, sounds have been associated with different button states -- if you have a sound card, make sure that your speakers are turned on.
The texture used for this example is 32 by 32 pixel JPEG file (1,014 bytes -- slightly less than 1K). Since the dimensions of the texture image is less than the dimensions of the button bar, the texture is tiled so that it covers the entire bar. If desired, the parameter textureButtonsOnly could have been used so that the gap between the two sets of buttons would not be covered with the texture. This is useful if used in conjunction with a background image file (see the background parameter).

If the Java class files and the image file is located in the same directory as the HTML, then the complete applet tag would be defined as illustrated below. Click on the PARAM name for detailed information about the parameter.

<APPLET CODE="TextURLButtonBar.class" WIDTH="368" HEIGHT="32">
<PARAM NAME="disableBadURL" VALUE="false">
<PARAM NAME="texture" VALUE="BTexture.JPG">
<PARAM NAME="grayBarBrighten" VALUE="-5">
<PARAM NAME="buttonBorders" VALUE="other">
<PARAM NAME="borderSize" VALUE="2">
<PARAM NAME="borderIntensity" VALUE="80">
<PARAM NAME="downShift" VALUE="true">
<PARAM NAME="downShiftAmt" VALUE="1">
<PARAM NAME="fontColor" VALUE="FFFFFF">
<PARAM NAME="fontColorOver" VALUE="DEFFFD">
<PARAM NAME="fontColorDown" VALUE="FFFF00">
<PARAM NAME="fontSize" VALUE="16">
<PARAM NAME="fontStyle" VALUE="bold">
<PARAM NAME="button1Text" VALUE="Home">
<PARAM NAME="button1Start" VALUE="0">
<PARAM NAME="button1Size" VALUE="84">
<PARAM NAME="button1Desc" VALUE="Return to the Home Page">
<PARAM NAME="button2Text" VALUE="Java">
<PARAM NAME="button2Start" VALUE="84">
<PARAM NAME="button2Size" VALUE="84">
<PARAM NAME="button2Desc" VALUE="Jump to the Java Page">
<PARAM NAME="button3Text" VALUE="Links">
<PARAM NAME="button3Start" VALUE="200">
<PARAM NAME="button3Size" VALUE="84">
<PARAM NAME="button3Desc" VALUE="Display Links to Related Sites">
<PARAM NAME="button4Text" VALUE="Contacts">
<PARAM NAME="button4Start" VALUE="284">
<PARAM NAME="button4Size" VALUE="84">
<PARAM NAME="button4Desc" VALUE="How to Contact Us">
<PARAM NAME="mouseEnterAudio" VALUE="AudioClips/drip.au">
<PARAM NAME="mouseClickAudio" VALUE="AudioClips/ip.au">
<PARAM NAME="buttonDownAudio" VALUE="AudioClips/bubble1.au">
</APPLET>
N otes on the Applet Parameters
The height and width values in the applet tag determine the height and width of button bar.
The grayBarBrighten parameter was used in this case to darken the automatically generated grayscale base bar so that the contrast between the texture and the text would be increased. If you do not want a grayscale base bar, then the drawGrayBase parameter can be set to "false".
The borderIntensity was increased from its default of 50 percent to 80 percent in order to accentuate the button borders.
The fontColor for the base button bar was set to white in order to provide maximum contrast between the grayscale texture and the button text. Note that any shade of gray (including black and white) is not altered by the grayBarBrighten parameter).
The audio clip locations are all based starting with the directory where the Java code is located. All parameters except the audio file parameters are based starting with the directory where the HTML page is located. Also, remember that the audio files must be in AU format -- not WAV or other formats.
The disableBadURL parameter is used so that you can click the buttons without having a page load over the example. Normally you would want to specify URLs for the buttons and omit the disableBadURL parameter.
Copyright © 1997 by Modern Minds, Inc.