
Undocumented Secrets of MATLAB
®
-Java Programming228
create icons from the latter to keep a consistent look-and-feel with the rest of MATLAB (we
could just as easily use our own external icon les):
% External icon file example
jSave.setIcon(javax.swing.ImageIcon('C:\Yair\save.gif'));
% JAR resource example
jarFile = fullfile(matlabroot,'/java/jar/mwt.jar');
iconsFolder = '/com/mathworks/mwt/resources/';
iconURI = ['jar:file:/' jarFile '!' iconsFolder 'save.gif'];
iconURI = java.net.URL(iconURI); % not necessary for external files
jSave.setIcon(javax.swing.ImageIcon(iconURI));
Note that setting a menu item’s icon automatically re-aligns all other ...