How can I pass a jList to workspace
2 次查看(过去 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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interaction Control 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!