å
·ä½å®ç°æ¹æ³ï¼å
¶å®ååç®åï¼åªéè¦ä¸ä¸ªå½æ°chgicon.m
该å½æ°ç¨çº¢è²æå表示ï¼
function chgicon(h,filename)
%CHGICON changes the figure icon.
%
CHGICON(H,FILENAME) changes the icon of a figure to an image specified by
%
the string FILENAME, where H is a handle to the figure. If the file is not
%
in the current directory or in a directory in the MATLAB path,specify the
%
full pathname of the location on your system. If FILENAME is not a valid
%
image file name, the function just removes the previous icon of the figure.
%
%
Example:
%
h = figure;
%
chgicon(h,'newIcon.png'); % replace 'newIcon.png' with your image
%
% IMPORTANT NOTES:
%
REPLACING THE MATLAB GUI ICON VIOLATES THE LICENSE AGREEMENT
% OF MATLAB. DO NOT USE THIS FUNCTION COMMERCIALLY.
%
%
Han Qun, Sept. 2005
%
Copyright 2005-2006 Han Qun
%
College of Precision Instrument and Opto-Electronics Engineering,
%
Tianjin University, 300072, P.R.China.
%
Email:
[email protected]%
$Revision: 1.0 $
$Date: 2005/12/2 $
if nargin<2
error('MATLAB:chgicon','%s','Too few input arguments!');
end
if nargin >2
error('MATLAB:chgicon','%s','Too many input arguments!');
end
newIcon = javax.swing.ImageIcon(filename);
javaFrame = get(h,'JavaFrame');
javaFrame.setFigureIcon(newIcon);å°ä¸é¢çå½æ°ä¿åå¨èªå·±è¦ä½¿ç¨çè·¯å¾ä¸ï¼åè°ç¨å³å¯ã
è°ç¨è¯å¥ï¼
h = figure
chgicon(h,'12.jpg');
å°±å¯ä»¥äºã
åæ¨å¹¿å°GUIä¸ä¹æ¯ä¸æ ·çï¼åªè¦å¨Create Fcnä¸è°ç¨è¿ä¸ªå½æ°å°±å¯ä»¥äºï¼
function figure1_CreateFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdatareserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
chgicon(hObject,'12.jpg');