Add Icons to GUI menus

Adds icons to the main figure menu of a given GUI
Updated 2 Dec 2013

View License

Given the handle of a GUI, this function attaches the icons stored in the "UserData" of each menu handle to the figure. As a result, the given GUI is enriched by properly implemented icons, added to the uimenu on the java level.

For the icons, filenames on the path, full qualified file names or java ImageIcon could be given.

Details can be found in the example.


% Attach icon data to the menu handles UserData

set(handles.Menu_File, 'UserData', '') % Also topevel handle could get the icon
set(handles.Menu_File_New, 'UserData', 'File_New.png')
set(handles.Menu_File_Load, 'UserData', 'File_Load.png')
set(handles.Menu_File_Save, 'UserData', 'File_Save.png') % get file on path
set(handles.Menu_File_Exit, 'UserData', 'File_Exit.png')

% Set the icons

Aknowledgment: Some of the ideas used here are based on the great work of Yair Altman ( as presented in and

Cite As

Alexander Mering (2024). Add Icons to GUI menus (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: setMenuIcon

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

Shortcoming removed as mentioned by Thierry

Comment added

Added aknowledgement