function varargout = ListBox__Test(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @ListBox__Test_OpeningFcn, ...
'gui_OutputFcn', @ListBox__Test_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function ListBox__Test_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
image_name_cell_array = {'gif1.gif', 'jpg1.jpg', 'png1.png', 'png2.png'};
handles.image_name_cell_array = image_name_cell_array;
handles.image_cell_array = {imread(image_name_cell_array{1}), ...
imread(image_name_cell_array{2}), ...
imread(image_name_cell_array{3}), ...
imread(image_name_cell_array{4})};
set(handles.listbox1,'String',image_name_cell_array);
guidata(hObject, handles);
function varargout = ListBox__Test_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function listbox1_Callback(hObject, eventdata, handles)
selected_index = get(hObject,'Value');
I = handles.image_cell_array{selected_index};
axes(handles.axes1);
image(I);
function listbox1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end