필터 지우기
필터 지우기

How can I pass a jList to workspace

조회 수: 1 (최근 30일)
Samah EL QASSAH
Samah EL QASSAH 2017년 7월 13일
Hi!
The following code is used to create a list with checkBoxes. When I run the simulation the list and all the information related to the list are indicated on the workspace.
% First create the data model
jList = java.util.ArrayList; % any java.util.List will be ok
jList.add(0,'First');
jList.add(1,'Second');
jList.add(2,'Third');
jList.add(3,'Forth');
jList.add(4,'Fifth');
jList.add(5,'Sixth');
jList.add(6,'and last');
% Next prepare a CheckBoxList component within a scroll-pane
jCBList = com.mathworks.mwswing.checkboxlist.CheckBoxList(jList);
jScrollPane = com.mathworks.mwswing.MJScrollPane(jCBList);
% Now place this scroll-pane within a Matlab container (figure or panel)
[jhScroll,hContainer] = javacomponent(jScrollPane,[10,10,100,100],gcf);
% Update some items' state programmatically
% jCBModel = jCBList.getCheckModel;
% jCBModel.checkAll;
% jCBModel.uncheckIndex(1);
% jCBModel.uncheckIndex(3);
% % Respond to checkbox update events
% jhCBModel = handle(jCBModel, 'CallbackProperties');
% set(jhCBModel, 'ValueChangedCallback', @myMatlabCallbackFcn);
I want to display the list by clicking on a pushbutton, so I add the above code to the function of a pushbutton as follows:
function pushbutton1_Callback(hObject, eventdata, handles)
% First create the data model
jList = java.util.ArrayList; % any java.util.List will be ok
jList.add(0,'First');
jList.add(1,'Second');
jList.add(2,'Third');
jList.add(3,'Forth');
jList.add(4,'Fifth');
jList.add(5,'Sixth');
jList.add(6,'and last');
assignin('base', 'jList', jlist);
% Next prepare a CheckBoxList component within a scroll-pane
jCBList = com.mathworks.mwswing.checkboxlist.CheckBoxList(jList);
jScrollPane = com.mathworks.mwswing.MJScrollPane(jCBList);
The list containing the checkboxes is displayed but I get nothing on the workspace.
How can I pass the list to the workspace?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by