Toolbar Applet documentation v. 1.0
Copyright SCAND LLC 2001
JTOOLBAR applet is useful component to create toolbars in internet/intranet application with flexible settings and rich functionality. One toolbar can contain different control elements at one time:

And more, you can specify more than one different toolbars for one applet and switch between there from JavaScript functions, depending on content. All events from toolbar elements can be processing in JavaScript with the help of notifications mechanism.
Toolbar applet can load content in two modes:
initialize it from PARAM tags, present in HTML that contain the applet
insert items directly from HTML with help of applet's public methods
In both cases it is possible to manage items of the toolbar applet using public methods of it. This can be done as from another Java applet that uses Toolbar applet, so from browser using JavaScript. The public methods are described below.
JTOOLBAR applet supports the next set of attributes:
BUTTONSTYLE
Style of applet. It can have two values: WINDOWS (default) or IE according to desired style.
BGCOLOR
Background color for the toolbar in HTML format.
To populate toolbar with buttons and choices you should specify parameters for each toolbar object in next format:
<param name="<object_name><number>" value="<object_attributes>">
where:
<object_name> is one of the next values:<number> indicates the sequential number of an item in initialization list, starts from zero. All objects should be numbered sequentially.
<object_attributes> - item-depended properties of object in <name>='<value>' format.
Tags for choices, menubars and menus should have closing tag param with empty value.
Example 1. Toolbar with one button, one edit field and choice.
<param name=toolbar0 value="id='ie_toolbar'">
<param name="button1" value="id='btn',image='icons/home.gif',width='27',height='26',id='home_button',statusmsg='Home',
tooltip='Home'">
<param name="edit2" value="id='edit1',label='Edit1:',text='text'">
<param name="choice3" value="id='choice1',statusmsg='Just combobox'">
<param name="choiceitem4" value="item1">
<param name="choiceitem5" value="item2">
<param name="choiceitem6" value="item3">
<param name="choiceitem7" value="item4">
<param name="choice8" value="">
<param name=toolbar9 value="">
For processing of events from menu you can specify the next names of script functions:
| Parameter name | Source | Event |
|---|---|---|
| ON_LOAD | jtoolbar applet (no arguments) | All data have been loaded into the toolbar and you can call any applet's method. |
| ON_CLICK | TBButton element | Any button in menu is pressed (or push button changed it state) |
| ON_CHANGE | TBChoice element | Choice element changes selected item. |
| ON_FOCUS_GAINED | TBEdit element | Edit element gained input focus. |
| ON_FOCUS_LOST | TBEdit element | Edit element lost input focus. |
| ON_ENTER | TBEdit element | Enter key was pressed in edit box. |
All functions (exclude ON_LOAD) receive single parameter - instance of event source object.
public Toolbar addToolbar(String id)
public void showToolbar(String id)
public Toolbar getToolbar(String id)
Toolbar's elements properties and methods
All elemets of toolbar have unique identifier, specified at initialization time and will not be changed later. For getting of it method getId() presents in all elements of toolbar.
Toolbar element
Toolbar element has only one property - unique identifier of toolbar. Bellow you can see example with declaration of empty toolbar:
Example 2. Declaration of empty toolbar
<param name=toolbar0
value="id='my_toolbar'">
<param name=toolbar1 value="">
public TBButton addButton(String id,
int width,
int height,
String strImage,
boolean isEnabled,
String status_msg,
String tooltip)
public TBButton addPushButton(String id,
int width,
int height,
String strImage,
boolean isPushed,
boolean isEnabled,
String status_msg,
String tooltip)
public TBChoice addChoice(String id,
String status_msg)
public TBEdit addChoice(String id, String label, String text [, int size])
public void addSeparator()
TBButton element
TBButton element has next list of attributesParameters id, image, width, height are mandatory for each button.
If many similar buttons are part of several toolbars, they can be described as named templates and used as references to template. Template for button can define all of button properties. Parameter for template has name tbutton<i> and has additional parameter name to define name of template. Then for this kind of button parameter name is necessary. Parameters state and pushed from template can be redefined in definition section.
Example 3. Button declarationa. With all atributes:
<param name="button4" value="id='btn',image='icons/home.gif',width='27',height='26',id='home_button',statusmsg='Home',
tooltip='Home'">
b. With using of template :
<param name="tbutton1" value="name='forward',image='icons/forward.gif',width='27',height='26',id='forward_button',statusmsg='Forward', tooltip='Forward'">
...
<param name="button3" value="name='forward'">
public boolean getState()
public void setState(boolean isPushed)
public void setEnabled(boolean isEnabled)
TBSeparator element
TBSeparator object describes as object with name separator. Value for it is ignoring. TBSeparator object has no methods.
Example 4. Separator declaration
<param name="separator4"
value="">
TBChoice element
Choice element has the next set of attributes:
Each element of choice desribing in next format: <param name="choiceitem<i>" value="<item_name>">
Each choice should be closed by choice parameter with empty value.
Example 5. Choice declaration<param name="choice3" value="id='choice1',statusmsg='Just combobox'">
<param name="choiceitem4" value="item1">
<param name="choiceitem5" value="item2">
<param name="choiceitem6" value="item3">
<param name="choiceitem7" value="item4">
<param name="choice8" value="">
TBChoice element extends standard java.awt.Choice class and all methods from it are available in TBChoice object (see JDK documentation)
TBEdit element
TBEdit element has the next set of attributes:
public String getText()
public void setText(String text)