Discussion:
How to change a gui's figure icon
(too old to reply)
Daniel
2008-06-26 15:21:02 UTC
Permalink
I am writing a large multi-windowed GUI in MATLAB and I
would like the window (figure) icon for each window to be
different.

What I mean when I say 'window icon' is the small picture
just to the left of the window's title, and the image that
shows up in the minimized version of the program on the
Windows taskbar.

I am familiar with adding icons to uibuttons, but do not
know how to change this property of a figure.

Thanks!
Daniel
matt dash
2008-06-26 15:46:02 UTC
Permalink
Post by Daniel
I am writing a large multi-windowed GUI in MATLAB and I
would like the window (figure) icon for each window to be
different.
What I mean when I say 'window icon' is the small picture
just to the left of the window's title, and the image that
shows up in the minimized version of the program on the
Windows taskbar.
I am familiar with adding icons to uibuttons, but do not
know how to change this property of a figure.
Thanks!
Daniel
warning('off','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');
jframe=get(handles.fig,'javaframe');
jIcon=javax.swing.ImageIcon('C:\program
files\matlab\r2007b\icons\icon.gif');
jframe.setFigureIcon(jIcon);

(while supplies last)
Daniel
2008-06-26 16:26:02 UTC
Permalink
Ok, tried it. But I receive the following error:

Error in ==> hddprofile_editor>setWindowTitleIcon at 71
jframe=get(handles.fig,'javaframe');

Apparently my handles structure contains no property 'fig'.
Any ideas? I am in R2007a.
matt dash
2008-06-26 16:50:19 UTC
Permalink
Post by Daniel
Error in ==> hddprofile_editor>setWindowTitleIcon at 71
jframe=get(handles.fig,'javaframe');
Apparently my handles structure contains no property 'fig'.
Any ideas? I am in R2007a.
Sorry, i pasted that out of a gui. handles.fig is the handle
of the figure whose icon you want to change.
d***@gmail.com
2008-07-29 12:01:54 UTC
Permalink
Post by matt dash
Post by Daniel
Error in ==> hddprofile_editor>setWindowTitleIcon at 71
jframe=get(handles.fig,'javaframe');
Apparently my handles structure contains no property 'fig'.
Any ideas? I am in R2007a.
Sorry, i pasted that out of a gui. handles.fig is the handle
of the figure whose icon you want to change.
Wow I didn't think that could be done at all. I have asked Mathworks
about that before and was told it can't be done.

I am considering selling some guis, so if I do that and pay the $15k+
I would be pretty annoyed that I couldn't brand it.

Thanks, matt_dash

Tim.
Bruno Luong
2008-07-29 12:23:01 UTC
Permalink
You should be aware that by changing the icone you would
violate Mathworks license agreement.

Bruno
Zulkifli
2010-02-23 09:30:37 UTC
Permalink
Post by matt dash
Post by Daniel
Error in ==> hddprofile_editor>setWindowTitleIcon at 71
jframe=get(handles.fig,'javaframe');
Apparently my handles structure contains no property 'fig'.
Any ideas? I am in R2007a.
Sorry, i pasted that out of a gui. handles.fig is the handle
of the figure whose icon you want to change.
What do you mean by pasted that out of a gui? then, where do you paste it?
Zulkifli
2010-02-23 09:32:07 UTC
Permalink
Post by matt dash
Post by Daniel
Error in ==> hddprofile_editor>setWindowTitleIcon at 71
jframe=get(handles.fig,'javaframe');
Apparently my handles structure contains no property 'fig'.
Any ideas? I am in R2007a.
Sorry, i pasted that out of a gui. handles.fig is the handle
of the figure whose icon you want to change.
What do you mean by pasted that out of a gui? then, where do you paste it?
uzumaki tornado
2010-06-16 20:09:04 UTC
Permalink
Post by Zulkifli
Post by matt dash
Post by Daniel
Error in ==> hddprofile_editor>setWindowTitleIcon at 71
jframe=get(handles.fig,'javaframe');
Apparently my handles structure contains no property 'fig'.
Any ideas? I am in R2007a.
Sorry, i pasted that out of a gui. handles.fig is the handle
of the figure whose icon you want to change.
What do you mean by pasted that out of a gui? then, where do you paste it?
use jframe=get(handles.output, 'javaframe');
Nickolai
2011-06-02 14:40:20 UTC
Permalink
Post by uzumaki tornado
Post by Zulkifli
Post by matt dash
Post by Daniel
Error in ==> hddprofile_editor>setWindowTitleIcon at 71
jframe=get(handles.fig,'javaframe');
Apparently my handles structure contains no property 'fig'.
Any ideas? I am in R2007a.
Sorry, i pasted that out of a gui. handles.fig is the handle
of the figure whose icon you want to change.
What do you mean by pasted that out of a gui? then, where do you paste it?
use jframe=get(handles.output, 'javaframe');
I tried this but I got a syntax error on the line:
files\matlab\r2010b\icons\icon.gif');

I commented it out, thinking it might have been a continuation of the previous line, but now when I run it instead of the MATLAB icon there's a java icon. Any ideas as to how to get it to change the program icon?
matt dash
2011-06-02 18:50:20 UTC
Permalink
Post by Nickolai
Post by uzumaki tornado
Post by Zulkifli
Post by matt dash
Post by Daniel
Error in ==> hddprofile_editor>setWindowTitleIcon at 71
jframe=get(handles.fig,'javaframe');
Apparently my handles structure contains no property 'fig'.
Any ideas? I am in R2007a.
Sorry, i pasted that out of a gui. handles.fig is the handle
of the figure whose icon you want to change.
What do you mean by pasted that out of a gui? then, where do you paste it?
use jframe=get(handles.output, 'javaframe');
files\matlab\r2010b\icons\icon.gif');
I commented it out, thinking it might have been a continuation of the previous line, but now when I run it instead of the MATLAB icon there's a java icon. Any ideas as to how to get it to change the program icon?
Don't do this. Changing the icon has a lot of unintended side effects that will screw up your whole matlab session. It's not worth it. Also as noted above, it goes against your license agreement.
Nickolai
2011-06-02 19:20:20 UTC
Permalink
Post by matt dash
Post by Nickolai
Post by uzumaki tornado
Post by Zulkifli
Post by matt dash
Post by Daniel
Error in ==> hddprofile_editor>setWindowTitleIcon at 71
jframe=get(handles.fig,'javaframe');
Apparently my handles structure contains no property 'fig'.
Any ideas? I am in R2007a.
Sorry, i pasted that out of a gui. handles.fig is the handle
of the figure whose icon you want to change.
What do you mean by pasted that out of a gui? then, where do you paste it?
use jframe=get(handles.output, 'javaframe');
files\matlab\r2010b\icons\icon.gif');
I commented it out, thinking it might have been a continuation of the previous line, but now when I run it instead of the MATLAB icon there's a java icon. Any ideas as to how to get it to change the program icon?
Don't do this. Changing the icon has a lot of unintended side effects that will screw up your whole matlab session. It's not worth it. Also as noted above, it goes against your license agreement.
I'm not really sure why changing the icon on an exe file would screw up my MATLAB session?

Also I'm not sure that poster really understood the question. What I'm trying to do is avoid the MATLAB icon showing up when I run my standalone application. If Mathworks didn't allow it I'm not sure they would write how-to's: http://www.mathworks.com/support/solutions/en/data/1-324E1D/?solution=1-324E1D

For the record, I have looked at that page but I think it assumes the user has visual studio, which I do not, and so I'm hoping this method might be easier.

I appreciate the concern but not doing it is simply not an option, I intend to distribute my program so having it show up with the MATLAB icon is unacceptable.
ny
2011-10-04 15:13:25 UTC
Permalink
Post by Nickolai
Also I'm not sure that poster really understood the question. What I'm trying to do is avoid the MATLAB icon showing up when I run my standalone application. If Mathworks didn't allow it I'm not sure they would write how-to's: http://www.mathworks.com/support/solutions/en/data/1-324E1D/?solution=1-324E1D
--> this is how to change the desktop icon (short-cut to the exe file), not the figure icon..
pink
2011-06-02 21:05:07 UTC
Permalink
Post by Daniel
I am writing a large multi-windowed GUI in MATLAB and I
would like the window (figure) icon for each window to be
different.
What I mean when I say 'window icon' is the small picture
just to the left of the window's title, and the image that
shows up in the minimized version of the program on the
Windows taskbar.
I am familiar with adding icons to uibuttons, but do not
know how to change this property of a figure.
Thanks!
Daniel
try to use this
function main_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to main (see VARARGIN)

% Choose default command line output for main
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

javaFrame = get(hObject,'JavaFrame');
javaFrame.setFigureIcon(javax.swing.ImageIcon('icon.JPG'));

icon.jpg located in the same folder with folders figures

pink
Nickolai
2011-06-02 21:30:08 UTC
Permalink
Post by pink
Post by Daniel
I am writing a large multi-windowed GUI in MATLAB and I
would like the window (figure) icon for each window to be
different.
What I mean when I say 'window icon' is the small picture
just to the left of the window's title, and the image that
shows up in the minimized version of the program on the
Windows taskbar.
I am familiar with adding icons to uibuttons, but do not
know how to change this property of a figure.
Thanks!
Daniel
try to use this
function main_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to main (see VARARGIN)
% Choose default command line output for main
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
javaFrame = get(hObject,'JavaFrame');
javaFrame.setFigureIcon(javax.swing.ImageIcon('icon.JPG'));
icon.jpg located in the same folder with folders figures
pink
Woot, it worked! For a second I didn't see it because Windows 7 grouped it with MATLAB down in the taskbar but it's there and it works. Thanks!
matt dash
2011-06-03 15:34:04 UTC
Permalink
Post by Nickolai
Post by pink
Post by Daniel
I am writing a large multi-windowed GUI in MATLAB and I
would like the window (figure) icon for each window to be
different.
What I mean when I say 'window icon' is the small picture
just to the left of the window's title, and the image that
shows up in the minimized version of the program on the
Windows taskbar.
I am familiar with adding icons to uibuttons, but do not
know how to change this property of a figure.
Thanks!
Daniel
try to use this
function main_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to main (see VARARGIN)
% Choose default command line output for main
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
javaFrame = get(hObject,'JavaFrame');
javaFrame.setFigureIcon(javax.swing.ImageIcon('icon.JPG'));
icon.jpg located in the same folder with folders figures
pink
Woot, it worked! For a second I didn't see it because Windows 7 grouped it with MATLAB down in the taskbar but it's there and it works. Thanks!
The license issue is because the license agreement says you are not allowed to cover or obscure any mathworks logo. As it happens, the default figure icon is a mathworks logo, so changing it could be interpreted as obscuring their logo. Whether or not they really care about this is anyone's guess.

When using the method described in this thread to change icons, i have had issues in windows xp (maybe later versions too, i can't recall) where after changing the icon on one figure, subsequent figures are created with no icon, which is annoying for identifying them in the taskbar. I have also has issues where after changing the figure icon of any figure, the pop up boxes in the editor that tell you the current values of variables stop appearing. Like you, i have no idea why this strange side effect happens, but I'm certain this is the cause. So keep that in mind before you implement this on something you're going to distribute... it might really annoy your users.
pink
2011-06-03 16:17:04 UTC
Permalink
Post by matt dash
Post by Nickolai
Post by pink
Post by Daniel
I am writing a large multi-windowed GUI in MATLAB and I
would like the window (figure) icon for each window to be
different.
What I mean when I say 'window icon' is the small picture
just to the left of the window's title, and the image that
shows up in the minimized version of the program on the
Windows taskbar.
I am familiar with adding icons to uibuttons, but do not
know how to change this property of a figure.
Thanks!
Daniel
try to use this
function main_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to main (see VARARGIN)
% Choose default command line output for main
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
javaFrame = get(hObject,'JavaFrame');
javaFrame.setFigureIcon(javax.swing.ImageIcon('icon.JPG'));
icon.jpg located in the same folder with folders figures
pink
Woot, it worked! For a second I didn't see it because Windows 7 grouped it with MATLAB down in the taskbar but it's there and it works. Thanks!
The license issue is because the license agreement says you are not allowed to cover or obscure any mathworks logo. As it happens, the default figure icon is a mathworks logo, so changing it could be interpreted as obscuring their logo. Whether or not they really care about this is anyone's guess.
When using the method described in this thread to change icons, i have had issues in windows xp (maybe later versions too, i can't recall) where after changing the icon on one figure, subsequent figures are created with no icon, which is annoying for identifying them in the taskbar. I have also has issues where after changing the figure icon of any figure, the pop up boxes in the editor that tell you the current values of variables stop appearing. Like you, i have no idea why this strange side effect happens, but I'm certain this is the cause. So keep that in mind before you implement this on something you're going to distribute... it might really annoy your users.
hi, mat
if ever it gives side effects, how the steps how to change the icon that true?
Nor Muzakkir
2011-06-14 13:00:18 UTC
Permalink
http://www.mathworks.com/support/contact_us/dev/javaframe.html

they are removing the JavaFrame property. probably to stop others from replacing the MATLAB icon logo.
yev33
2012-11-06 09:28:05 UTC
Permalink
Post by pink
Post by Daniel
I am writing a large multi-windowed GUI in MATLAB and I
would like the window (figure) icon for each window to be
different.
What I mean when I say 'window icon' is the small picture
just to the left of the window's title, and the image that
shows up in the minimized version of the program on the
Windows taskbar.
I am familiar with adding icons to uibuttons, but do not
know how to change this property of a figure.
Thanks!
Daniel
try to use this
function main_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to main (see VARARGIN)
% Choose default command line output for main
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
javaFrame = get(hObject,'JavaFrame');
javaFrame.setFigureIcon(javax.swing.ImageIcon('icon.JPG'));
icon.jpg located in the same folder with folders figures
pink
Thanks! It works great!

Loading...