Variable amount of checkboxes in listbox (programmatic GUI)
Afficher commentaires plus anciens
I have in my programmatic GUI the following listbox:
h.listbox = uicontrol('style','listbox','units','pixels',...
'position',[10,175,200,200],...
'string',components_index);
The entire program gives me the following output:

What I now want, is that in front of every stock, I have a checkbox. Keep in mind that the amount of stocks is variable.
Can anyone point towards a solution?
Thanks in advance,
Jonathan
Réponse acceptée
Plus de réponses (1)
Yair Altman
le 4 Sep 2014
There are actually 2 built-in controls that you could use within Matlab:
- com.jidesoft.swing.CheckboxList
- com.mathworks.mwswing.checkboxlict.CheckBoxList
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,'and last');
jCBList = com.mathworks.mwswing.checkboxlist.CheckBoxList(jList);
jScrollPane = com.mathworks.mwswing.MJScrollPane(jCBList);
[jhCBList,hContainer] = javacomponent(jScrollPane,[10,10,80,65],gcf);
set(jCBList, 'ValueChangedCallback', @myMatlabCallbackFcn);
jCBModel = jCBList.getCheckModel;
jCBModel.checkAll;
jCBModel.uncheckIndex(1);
jCBModel.uncheckIndex(3)

2 commentaires
Sarfudeen
le 7 Jan 2015
how to loop over multiple files selection in this....
André Luiz Lourenço
le 8 Mai 2019
How can I put this listbox into a panel control?
Catégories
En savoir plus sur App Building dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!