Filter löschen
Filter löschen

How can I pass a jList to workspace

1 Ansicht (letzte 30 Tage)
Samah EL QASSAH
Samah EL QASSAH am 13 Jul. 2017
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?

Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by