필터 지우기
필터 지우기

with which keyword can i handle the java component in GUI?

조회 수: 2 (최근 30일)
Tong Wang
Tong Wang 2018년 4월 24일
댓글: Tong Wang 2018년 4월 25일
i would like to change the java slider property after i click a button, the problem is, normally we use the 'handles.X' to get in the thing which we want to handle. But with java component i got this reply.
Reference to non-existent field 'jSlider2'.
this is the callback code
function Pushbutton_Callback(hObject, eventdata, handles)
set(handles.jSlider2,'Maximum',5);
end
this is the slider definition, which i wrote in OpeningFcn
jSlider2 = javax.swing.JSlider(1,10,1);
jSlider2 = javacomponent(jSlider2, [40,90,500,40]);
set(jSlider2, 'MajorTickSpacing',1, 'PaintTicks',true,'PaintLabels',true);

채택된 답변

Geoff Hayes
Geoff Hayes 2018년 4월 25일
Tong - try saving the jSlider2 to the handles structure in your OpeningFcn
jSlider2 = javax.swing.JSlider(1,10,1);
handles.jSlider2 = javacomponent(jSlider2, [40,90,500,40]);
set(handles.jSlider2, 'MajorTickSpacing',1, 'PaintTicks',true,'PaintLabels',true);
guidata(hObject, handles);
The call to guidata is important as it will save the updated handles structure with the jSlider2 field.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by