欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Matlab GUI 界面编程:界面左上角图标更改

程序员文章站 2022-06-04 13:16:43
...

Matlab GUI 界面编程:界面左上角图标更改

在界面的m文件中,找到界面的OpeningFcn函数

% --- Executes just before day1 is made visible.
function day1_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 day1 (see VARARGIN)
h = handles.figure1; %获取句柄
newIcon = javax.swing.ImageIcon('图标.jpg'); %读取图片文件
figFrame = get(h,'JavaFrame');
figFrame.setFigureIcon(newIcon);
% Choose default command line output for day1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);