Variable amount of checkboxes in listbox (programmatic GUI)

1 回表示 (過去 30 日間)
Jonathan
Jonathan 2014 年 8 月 26 日
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

採用された回答

Adam
Adam 2014 年 8 月 26 日
I don't think that is possible with Matlab UI controls. However, if you don't mind doing some experimentation with undocumented controls, the following information on Yair Altman's excellent blog may help:
  2 件のコメント
Jonathan
Jonathan 2014 年 8 月 27 日
I eventually went for uitable. YIDE combo boxes is a bit difficult for my programming skills :P. But thanks!
If anyone is interested, using the following code will give want I wanted.
components_index = {'one1','two2','three3'};
h.table = uitable('units', 'pixels', 'position', [10, 100, 200, 200], ...
'columnname', {'Yes/No'},...
'columnformat',{'logical'},...
'ColumnEditable', true,...
'rowname',components_index,...
'data',false(numel(components_index),1));
Adam
Adam 2014 年 8 月 27 日
Yeah, I've shied away from the hardcore Jide UI programming too for now and have also been using uitable of late. I don't like it at all and it took me probably as long to get right as Jide would, but it does a job so glad you got that to work for you.

サインインしてコメントする。

その他の回答 (1 件)

Yair Altman
Yair Altman 2014 年 9 月 4 日
There are actually 2 built-in controls that you could use within Matlab:
  1. com.jidesoft.swing.CheckboxList
  2. com.mathworks.mwswing.checkboxlict.CheckBoxList
Usage example (more details in my Matlab-Java book):
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 件のコメント
Sarfudeen
Sarfudeen 2015 年 1 月 7 日
how to loop over multiple files selection in this....
André Luiz Lourenço
André Luiz Lourenço 2019 年 5 月 8 日
How can I put this listbox into a panel control?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by