function initialize(obj,axes_handle)
[obj.j_comp, temp] = javacomponent('javax.swing.JButton',[],obj.fig_handle);
obj.h_container = handle(temp);
set(obj.h_container,'BusyAction','queue','Interruptible','off');
obj.axes_handle = axes_handle;
if verLessThan('matlab', '8.4')
size_cb = {'Position', 'PostSet'};
else
size_cb = {'SizeChanged'};
end
obj.L1 = addlistener(axes_handle,'XLim','PostSet', @(~,~)obj.listenerCallback);
obj.L2 = addlistener(axes_handle, size_cb{:}, @(~,~) obj.listenerCallback);
set(obj.j_comp,'PropertyChangeCallback',@(~,~)obj.renderDataCallback());
end
function listenerCallback(obj)
try
if obj.last_string_index == 1
obj.last_string_index = 2;
obj.j_comp.setText('a');
else
obj.last_string_index = 1;
obj.j_comp.setText('b');
end
end
end
end
4 Comments
Walter Roberson (view profile)
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/368964-queue-addlistener-events-or-place-event-on-edt#comment_509314
Jim Hokanson (view profile)
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/368964-queue-addlistener-events-or-place-event-on-edt#comment_509321
Jim Hokanson (view profile)
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/368964-queue-addlistener-events-or-place-event-on-edt#comment_509354
Jim Hokanson (view profile)
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/368964-queue-addlistener-events-or-place-event-on-edt#comment_523075
Sign in to comment.