jsMenu object explained

The jsMenu object is a simple and quick way to add menues to the BlueJ tools menu. It allows the script writer to add a menu Item without knowing the exact detail of the undelyng mechanism. The methods available are the following.

jsMenu.addAction (String menuName, String menuAction )

The above method adds a menu with the given menuName that will perform the given menuAction when selected. a menuAction is just some javascript code that will be executed by the interpreter. One most useful example is:

jsMenu.addAction ('Show Console',  'jsConsole.setVisible(true);'  );

The above javascript line will add a menu to the current menu with the title "Show Console" that when selected will just show the javascript console. NOTE: The command is queue as all other commands to the stream of events sent to jsEvent, this means that while your script is busy executing it will not be possible for the "system" to execute the given command.

addAction() returns an object that represent the action we would like to be performed. This object can bre retained since it can be used later to remove the given menu.

jsmenu.getActions()

Returns an array of actions that you can then inspect or use to remove all menues related to BlueJscript.

jsMenu.removeAction (MenuAction anAction)

Removes a single action from the menu tree.