CookBSH Tutorial

To add <bsh> to your existing tag library, say CookSwing, add the following code:

CookBSH.setupTagLibrary (CookSwing.getSwingTagLibrary ());

The type of the object this tag creates depends on the beanshell code. BeanShell code can be inserted in two ways: inside the tag, or in another file/resource specified using src attribute.

<button text="Button 1">
	<bsh func="addActionListener">
		import java.awt.event.ActionListener;

actionPerformed( e ) { statusBar.setText (e.getSource ().getText () + " Pressed"); }

return (ActionListener)this; </bsh> </button> <button text="Button 2"> <!-- calling an external BSH code (identical to the bsh code above) --> <bsh func="addActionListener" src="examples/cookbsh/action.bsh"/> </button>