New menu is created and added to the menu bar.
In[115]:=
![]()
Menu item is added to the menu.
In[116]:=
![]()
Listener class for menu action is loaded.
In[117]:=
![]()
In[118]:=
![]()
A command handler is defined and is set to the listener.
In[119]:=
![handleItemApply[event_, command_] := JavaBlock[Module[ {saved}, saved = frame @ getTitle[] ; ... quot;handleItemApply was called..."] ; frame @ setTitle[saved] ; ReleaseObject[event] ; ]]](../HTMLFiles/index_302.gif)
In[120]:=
![]()
The listener itself is attached to the menu item.
In[121]:=
![]()
BEFORE USING ANY MENU COMMAND DEFINED IN MATHEMATICA, SHARING FRONTEND SHOULD BE STARTED.
In[122]:=
![]()
Now clicking a menu item makes Mathematica print a string. Because this 'calculation' is done very fast, it might be impossible to see the change of frame's title.
![]()
![]()
![]()
(sharing) In[123]:=
![LongCalculation[notify_: False] := Module[ {sum = 0, cnt = 0}, Do[ sum += Random[] ; ++ cnt ... rame @ setTitle["cnt=50000, sum=" <> ToString[sum]]] ], {100000}] ; Print[sum] ]](../HTMLFiles/index_315.gif)
(sharing) In[124]:=
![]()
The definition of the handlerItemFilter[ ] is changed.
(sharing) In[125]:=
![handleItemApply[event_, command_] := JavaBlock[Module[ {saved}, saved = frame @ getTitle[] ; ... called..."] ; LongCalculation[True] ; frame @ setTitle[saved] ; ReleaseObject[event] ; ]]](../HTMLFiles/index_321.gif)
Clicking a menu item invokes this command handler.
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
Converted by Mathematica (July 17, 2003)