问题
I'm trying to create a calendar using MATLAB GUI. I found this tutorial and created calendar:
com.mathworks.mwswing.MJUtilities.initJIDE;
% Put calendar to my figure
jPanel = com.jidesoft.combobox.DateChooserPanel;
[hPanel,hContainer] = javacomponent(jPanel,[500,130,200,200],gcf);
set(handles.hPanel, 'MousePressedCallback', ...
@(src, evnt)CellSelectionCallback(src, evnt, handles));
set(handles.hPanel, 'KeyPressedCallback', ...
@(src, evnt)CellSelectionCallback(src, evnt, handles));
Also I have Edit Text object. Lets try to put Selected Value to it! I use excaza's code:
function CellSelectionCallback(hObject, evnt, handles)
hModel = handle(hObject.getSelectionModel, 'CallbackProperties');
selectedDate = hModel.getSelectedDate();
dayNumber = get(selectedDate,'Date');
handles.edit_start.String = num2str(dayNumber);
handles.newNote(3) = {dayNumber};
guidata(handles.figure1, handles);
So I can read selected date and put it anywhere.
Problem
Code works only in Debug Mode. In normal mode my Edit Text Object (edit_start) stays empty!
来源:https://stackoverflow.com/questions/40374942/function-works-only-in-debug-mode-matlab-gui