How can I pass a jList to workspace

1 次查看(过去 30 天)
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