Undocumented Secrets of MATLAB
®
-Java Programming188
Unlike uitables, uitrees do not have a default context menu, activated on mouse right-click.
This is relatively easy to set up, using a Java Swing popup menu (Note the similarities and slight
differences compared with the PopupMenu that was presented in Section 3.6):
62
% Prepare the context menu (note the use of HTML labels)
menuItem1 = javax.swing.JMenuItem('action #1');
menuItem2 = javax.swing.JMenuItem('<html><b>action #2');
menuItem3 = javax.swing.JMenuItem('<html><i>action #3');
% Set the menu items' callbacks
set(menuItem1,'ActionPerformedCallback',@myFunc1);
set(menuItem2,'ActionPerformedCallback',{@myfunc2,data1,data2});
set(menuItem3,'ActionPerformedCallback','disp ''action #3. . .'' '); ...