MATLAB: How to remove callback from a java component

guijavamatlab gui

As you can see, i have here a java slider in matlab gui, i need to set a 'MouseReleasedCallback' when i use mouse to control the slider, then i also need a 'StateChangedCallback' for edit box on the right side (Number changes in edit box won't lead to 'MouseReleasedCallback', because there is no mouse action) .
The mindset is that, in initialization of this jslider a 'MouseReleasedCallback' will be set, then when edit box is called, a 'StateChangedCallback' for jslider will be created, then it leads to that callbackfunc, use guidata to save result, after that the 'StateChangedCallback' will be removed.(Or there will be two callback properties for one slider) i have code like this, the" set(handles.jsh,'StateChangedCallback',{}) " seems doesn't work. I suppose it should be a combination of java statement with matlab code , i have searched it in web for a whole day, but just no results, could anyone please give me a tip to completely remove this callback?
function Slider1_Edit_Callback(hObject, eventdata, handles)
set(handles.jSlider1,'StateChangedCallback',{@mycallback_jSlider1,handles})
TextValue = str2double(get(handles.Slider1_Edit,'String'));
set(handles.jSlider1,'Value',TextValue);
guidata(hObject,handles);
set(handles.jSlider1,'StateChangedCallback',{})
guidata(hObject,handles);
end
EDIT: Sorry for unclear description.
With the slider value changing in the edit callback function above should lead to the slider callback @mycallback_jSlider1, which is
function mycallback_jSlider1(hObject, eventdata, handles)
SliderValue = get(handles.jSlider1,'Value');
Images = evalin('base','Images');
imshow(Images{SliderValue},'Parent',handles.axes1);
end
By doesn't work i mean: I set breakpoints to @mycallback_jSlider1, when i change number in edit box, it shows that the @mycallback_jSlider1 was never be called…More stranger is that if i set breakpoint in @Slider1_Edit_Callback in lines before "set(handles.jSlider1,'StateChangedCallback',{})", it will call @mycallback_jSlider1, but if i set breakpoint after "set(handles.jSlider1,'StateChangedCallback',{})", it shows @mycallback_jSlider1 wasn't be called…..

Best Answer

Ok, I understand the problem now. I'll leave my previous answer in since it was related to the question in the title, even though it doesn't really add much, but to answer the new question:
Add a 'drawnow' instruction after setting the slider value before you remove its callback:
function Slider1_Edit_Callback(hObject, eventdata, handles)
set(handles.jSlider1,'StateChangedCallback',{@mycallback_jSlider1,handles})
TextValue = str2double(get(handles.Slider1_Edit,'String'));
set(handles.jSlider1,'Value',TextValue);
drawnow
set(handles.jSlider1,'StateChangedCallback',{})
end
I removed the guidata calls as they don't seem to be necessary there.