<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: CheckboxList	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/checkboxlist/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/checkboxlist?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=checkboxlist</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Sat, 28 Nov 2020 14:07:30 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.3</generator>
	<item>
		<title>
		By: Jianfei		</title>
		<link>https://undocumentedmatlab.com/articles/checkboxlist#comment-509337</link>

		<dc:creator><![CDATA[Jianfei]]></dc:creator>
		<pubDate>Sat, 28 Nov 2020 14:07:30 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5012#comment-509337</guid>

					<description><![CDATA[I have tried the MathWorks CheckBoxList in Matlab 2015b. For whatever the reason, I can&#039;t change the font properties. I can change the font color, but changing font properties like font family, font size, bold and italic will not take any effect.]]></description>
			<content:encoded><![CDATA[<p>I have tried the MathWorks CheckBoxList in Matlab 2015b. For whatever the reason, I can&#8217;t change the font properties. I can change the font color, but changing font properties like font family, font size, bold and italic will not take any effect.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Arun Joe Joseph		</title>
		<link>https://undocumentedmatlab.com/articles/checkboxlist#comment-507073</link>

		<dc:creator><![CDATA[Arun Joe Joseph]]></dc:creator>
		<pubDate>Tue, 05 Nov 2019 10:22:55 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5012#comment-507073</guid>

					<description><![CDATA[Is it possible to use this Matlab CheckboxList along with GUIDE? I tried using this in a GUIDE app, and it seems that I cannot pass GUIDE arguments like handles structure to myMatlabCallbackFcn? 


Also In myMatlabCallbackFcn, how can I access the Checked Values, as in the names corresponding to the checked values? I tried using jCBList.getCheckedValues, but I am not able to access jCBList inside my callback function.]]></description>
			<content:encoded><![CDATA[<p>Is it possible to use this Matlab CheckboxList along with GUIDE? I tried using this in a GUIDE app, and it seems that I cannot pass GUIDE arguments like handles structure to myMatlabCallbackFcn? </p>
<p>Also In myMatlabCallbackFcn, how can I access the Checked Values, as in the names corresponding to the checked values? I tried using jCBList.getCheckedValues, but I am not able to access jCBList inside my callback function.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/checkboxlist#comment-418421</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Thu, 11 Jan 2018 11:49:59 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5012#comment-418421</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/checkboxlist#comment-417722&quot;&gt;JoeB&lt;/a&gt;.

@JoeB - the Mathworks&#039; &lt;code&gt;CheckBoxList&lt;/code&gt; has a bug with this: the list is indeed disabled in the sense that you cannot change the selected item(s), but it is not fully disabled in the sense that you can still check/uncheck the checkboxes, even if you try to do &lt;code&gt;jCBList.getCellRenderer.setEnabled(0)&lt;/code&gt;. 

Instead, you can use JIDE&#039;s &lt;code&gt;CheckBoxList&lt;/code&gt;, which does not have this bug.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/checkboxlist#comment-417722">JoeB</a>.</p>
<p>@JoeB &#8211; the Mathworks&#8217; <code>CheckBoxList</code> has a bug with this: the list is indeed disabled in the sense that you cannot change the selected item(s), but it is not fully disabled in the sense that you can still check/uncheck the checkboxes, even if you try to do <code>jCBList.getCellRenderer.setEnabled(0)</code>. </p>
<p>Instead, you can use JIDE&#8217;s <code>CheckBoxList</code>, which does not have this bug.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: JoeB		</title>
		<link>https://undocumentedmatlab.com/articles/checkboxlist#comment-417722</link>

		<dc:creator><![CDATA[JoeB]]></dc:creator>
		<pubDate>Tue, 19 Dec 2017 16:14:18 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5012#comment-417722</guid>

					<description><![CDATA[Hi Yair, Thanks for this. When I try the following code in ML 2017a, I get a list that returns IsEnabled as false but still allows the user to change the checkbox values and does not appear greyed out. Any idea what I&#039;m missing? Thanks:

&lt;pre lang=&quot;matlab&quot;&gt;
% First create the data model
jList = java.util.ArrayList;  % any java.util.List will be ok
jList.add(0,&#039;First&#039;);
jList.add(1,&#039;Second&#039;);
jList.add(2,&#039;Third&#039;);
jList.add(3,&#039;and last&#039;);
 
% 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,80,65],gcf);

jCBList.setEnabled(0)
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>Hi Yair, Thanks for this. When I try the following code in ML 2017a, I get a list that returns IsEnabled as false but still allows the user to change the checkbox values and does not appear greyed out. Any idea what I&#8217;m missing? Thanks:</p>
<pre lang="matlab">
% 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,'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,80,65],gcf);

jCBList.setEnabled(0)
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/checkboxlist#comment-417212</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Sun, 03 Dec 2017 11:59:04 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5012#comment-417212</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/checkboxlist#comment-405880&quot;&gt;Fabrizio&lt;/a&gt;.

@Fabrizio - &lt;pre lang=&quot;Matlab&quot;&gt;jCBList.setEnabled(false)  % or: jCBList.setEnabled(0)&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/checkboxlist#comment-405880">Fabrizio</a>.</p>
<p>@Fabrizio &#8211; </p>
<pre lang="Matlab">jCBList.setEnabled(false)  % or: jCBList.setEnabled(0)</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Miloslav		</title>
		<link>https://undocumentedmatlab.com/articles/checkboxlist#comment-413126</link>

		<dc:creator><![CDATA[Miloslav]]></dc:creator>
		<pubDate>Tue, 05 Sep 2017 12:01:13 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5012#comment-413126</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/checkboxlist#comment-337440&quot;&gt;Sebastian&lt;/a&gt;.

I&#039;m also interested in modifying list elements. 
I&#039;m using R2016b on Windows (x64).

I could modify the existing elements like:
&lt;pre lang=&quot;matlab&quot;&gt;
cbmodel = javax.swing.DefaultListModel;
cbmodel.addElement(&#039;Test A&#039;); %any of the following two will work
cbmodel.insertElementAt(&#039;Test B&#039;, 1);

jCBList = com.mathworks.mwswing.checkboxlist.CheckBoxList(cbmodel);
jScrollPane2 = com.mathworks.mwswing.MJScrollPane(jCBList);

%draw it
[jhScroll,hContainer] = javacomponent(jScrollPane2,[0,0,200,200],gcf);
set(hContainer,&#039;units&#039;,&#039;norm&#039;, &#039;tag&#039;,&#039;modelList&#039;); %set &#039;tag&#039; to find it later

%to modify the existing elements
oList = findobj(&#039;Tag&#039;,&#039;nameList&#039;); %return JavaWrapper
zz = oList.JavaPeer; %return MJScroollPane
zzz = zz.getViewport().getView(); % return CheckBoxList
list = zzz.getModel(); % return DefaultListModel
% or directly
%list = oList.JavaPeer.getViewport().getView().getModel();

list.clear(); % clear the list
methods(list);
% will print you this methods
%DefaultListModel        equals                  isEmpty                 set                     
%add                     firstElement            lastElement             setElementAt            
%addElement              get                     lastIndexOf             setSize                 
%addListDataListener     getClass                notify                  size                    
%capacity                getElementAt            notifyAll               toArray                 
%clear                   getListDataListeners    remove                  toString                
%contains                getListeners            removeAllElements       trimToSize              
%copyInto                getSize                 removeElement           wait                    
%elementAt               hashCode                removeElementAt         
%elements                indexOf                 removeListDataListener  
%ensureCapacity          insertElementAt         removeRange             

list.addElement(&#039;TEST&#039;);
list.addElement(&#039;Element 2&#039;);
list.setElementAt(&#039;replaced previous TEST&#039;,0);
list.insertElementAt(&#039;TEST 2&#039;,1); % this will allow you really add more elements to the list without exception &quot;IndexOutOfBoundsException&quot;

%OR
%now you can manipulate the list elements by replacing the model with the new one
model = javax.swing.DefaultListModel;
model.addElement(&#039;new TEST&#039;); %it works if you add 1-3 elements
%now, add new element to the list at certain position
model.insertElementAt(&#039;blabla&#039;, 1); % second argument is index, start with 0

zzz.setModel(model); % and replace old model with new one in the CheckBoxList
&lt;/pre&gt;
If you add mode elements (using addElement method) than the original list had you will get :
&quot;Exception in thread &quot;AWT-EventQueue-0&quot; java.lang.IndexOutOfBoundsException: Index: 1, Size: 1&quot;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/checkboxlist#comment-337440">Sebastian</a>.</p>
<p>I&#8217;m also interested in modifying list elements.<br />
I&#8217;m using R2016b on Windows (x64).</p>
<p>I could modify the existing elements like:</p>
<pre lang="matlab">
cbmodel = javax.swing.DefaultListModel;
cbmodel.addElement('Test A'); %any of the following two will work
cbmodel.insertElementAt('Test B', 1);

jCBList = com.mathworks.mwswing.checkboxlist.CheckBoxList(cbmodel);
jScrollPane2 = com.mathworks.mwswing.MJScrollPane(jCBList);

%draw it
[jhScroll,hContainer] = javacomponent(jScrollPane2,[0,0,200,200],gcf);
set(hContainer,'units','norm', 'tag','modelList'); %set 'tag' to find it later

%to modify the existing elements
oList = findobj('Tag','nameList'); %return JavaWrapper
zz = oList.JavaPeer; %return MJScroollPane
zzz = zz.getViewport().getView(); % return CheckBoxList
list = zzz.getModel(); % return DefaultListModel
% or directly
%list = oList.JavaPeer.getViewport().getView().getModel();

list.clear(); % clear the list
methods(list);
% will print you this methods
%DefaultListModel        equals                  isEmpty                 set                     
%add                     firstElement            lastElement             setElementAt            
%addElement              get                     lastIndexOf             setSize                 
%addListDataListener     getClass                notify                  size                    
%capacity                getElementAt            notifyAll               toArray                 
%clear                   getListDataListeners    remove                  toString                
%contains                getListeners            removeAllElements       trimToSize              
%copyInto                getSize                 removeElement           wait                    
%elementAt               hashCode                removeElementAt         
%elements                indexOf                 removeListDataListener  
%ensureCapacity          insertElementAt         removeRange             

list.addElement('TEST');
list.addElement('Element 2');
list.setElementAt('replaced previous TEST',0);
list.insertElementAt('TEST 2',1); % this will allow you really add more elements to the list without exception "IndexOutOfBoundsException"

%OR
%now you can manipulate the list elements by replacing the model with the new one
model = javax.swing.DefaultListModel;
model.addElement('new TEST'); %it works if you add 1-3 elements
%now, add new element to the list at certain position
model.insertElementAt('blabla', 1); % second argument is index, start with 0

zzz.setModel(model); % and replace old model with new one in the CheckBoxList
</pre>
<p>If you add mode elements (using addElement method) than the original list had you will get :<br />
&#8220;Exception in thread &#8220;AWT-EventQueue-0&#8243; java.lang.IndexOutOfBoundsException: Index: 1, Size: 1&#8221;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Fabrizio		</title>
		<link>https://undocumentedmatlab.com/articles/checkboxlist#comment-405880</link>

		<dc:creator><![CDATA[Fabrizio]]></dc:creator>
		<pubDate>Wed, 03 May 2017 09:39:33 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5012#comment-405880</guid>

					<description><![CDATA[Hi Yair and many compliments for your post.
I&#039;m a beginner with Java in Matlab and I&#039;ve a simple question to ask. 
After a selection,  I wish to disable the panel containing the Mathworks checkboxlist.

I noticed that 
&lt;pre lang=&quot;matlab&quot;&gt; 
set(findall(hpanel, &#039;-property&#039;, &#039;enable&#039;), &#039;enable&#039;, &#039;off&#039;) 
&lt;/pre&gt; 
doesn&#039;t work.

Furthermore
&lt;pre lang=&quot;matlab&quot;&gt;
jhScroll.setEnable(0)
&lt;/pre&gt; 
doen&#039;t produce any effects on the java component.
On the contrary  jhScroll.setVisible works as the name suggests.

Where do I fail? Is it a known issue?
Thanks in advance for your reply.]]></description>
			<content:encoded><![CDATA[<p>Hi Yair and many compliments for your post.<br />
I&#8217;m a beginner with Java in Matlab and I&#8217;ve a simple question to ask.<br />
After a selection,  I wish to disable the panel containing the Mathworks checkboxlist.</p>
<p>I noticed that </p>
<pre lang="matlab"> 
set(findall(hpanel, '-property', 'enable'), 'enable', 'off') 
</pre>
<p>doesn&#8217;t work.</p>
<p>Furthermore</p>
<pre lang="matlab">
jhScroll.setEnable(0)
</pre>
<p>doen&#8217;t produce any effects on the java component.<br />
On the contrary  jhScroll.setVisible works as the name suggests.</p>
<p>Where do I fail? Is it a known issue?<br />
Thanks in advance for your reply.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Xiangrui Li		</title>
		<link>https://undocumentedmatlab.com/articles/checkboxlist#comment-380873</link>

		<dc:creator><![CDATA[Xiangrui Li]]></dc:creator>
		<pubDate>Tue, 21 Jun 2016 00:45:01 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5012#comment-380873</guid>

					<description><![CDATA[Following Yair&#039;s nice information, I played with JIDE checkbox list, and figured out the way to add/remove checkbox list dynamically for my purpose. Compared to my previous post using two special characters as checked and unchecked boxes, JIDE CheckBoxList contains true checkbox, so there is no need to compute the list item by mouse click location, which depends on font size.

Another feature which fits my need very well is that JIDE CheckBoxList can be ClickInCheckBoxOnly, which separates check event and selection event. This is different from mathworks CheckBoxList where mouse selection always does check/uncheck, but much like uitable, while uitable has no programmatic way to select an item. 

Here is some sample code:
&lt;pre lang=&quot;matlab&quot;&gt;% set up model
jCBList = com.jidesoft.swing.CheckBoxList;
jCBList.setModel(javax.swing.DefaultListModel); % dynamic items
% jCBList.ClickInCheckBoxOnly = true; % it&#039;s default
jCBList.setSelectionMode(0); % I need single selection

% Now display onscreen:
jScrollPane = com.mathworks.mwswing.MJScrollPane(jCBList);
javacomponent(jScrollPane, [10,40,80,80], gcf);

% add some items and set check/selecttion
jCBList.getModel.addElement(&#039;First&#039;); % add item to end
jCBList.getModel.addElement(&#039;Third&#039;); % add item to end
jCBList.getModel.insertElementAt(&#039;Second&#039;, 1); % insert item as 2nd item
% jCBList.getModel.removeElementAt(1); % remove 2nd item
jCBList.addCheckBoxListSelectedIndex(2); % check 3rd item
jCBList.setSelectedIndex(1); % select 2nd item (highlight)

% set up callback
h = handle(jCBList, &#039;CallbackProperties&#039;);
set(h, &#039;MouseClickedCallback&#039;, @mouseFcn);

% callback
function mouseFcn(h, ~)
   fprintf(&#039;Item %g selected\n&#039;, h.getSelectedIndex+1);
   fprintf(&#039;Item(s) &#039;);
   fprintf(&#039;%g &#039;, h.getCheckBoxListSelectedIndices+1);
   fprintf(&#039;checked\n&#039;);
end
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>Following Yair&#8217;s nice information, I played with JIDE checkbox list, and figured out the way to add/remove checkbox list dynamically for my purpose. Compared to my previous post using two special characters as checked and unchecked boxes, JIDE CheckBoxList contains true checkbox, so there is no need to compute the list item by mouse click location, which depends on font size.</p>
<p>Another feature which fits my need very well is that JIDE CheckBoxList can be ClickInCheckBoxOnly, which separates check event and selection event. This is different from mathworks CheckBoxList where mouse selection always does check/uncheck, but much like uitable, while uitable has no programmatic way to select an item. </p>
<p>Here is some sample code:</p>
<pre lang="matlab">% set up model
jCBList = com.jidesoft.swing.CheckBoxList;
jCBList.setModel(javax.swing.DefaultListModel); % dynamic items
% jCBList.ClickInCheckBoxOnly = true; % it's default
jCBList.setSelectionMode(0); % I need single selection

% Now display onscreen:
jScrollPane = com.mathworks.mwswing.MJScrollPane(jCBList);
javacomponent(jScrollPane, [10,40,80,80], gcf);

% add some items and set check/selecttion
jCBList.getModel.addElement('First'); % add item to end
jCBList.getModel.addElement('Third'); % add item to end
jCBList.getModel.insertElementAt('Second', 1); % insert item as 2nd item
% jCBList.getModel.removeElementAt(1); % remove 2nd item
jCBList.addCheckBoxListSelectedIndex(2); % check 3rd item
jCBList.setSelectedIndex(1); % select 2nd item (highlight)

% set up callback
h = handle(jCBList, 'CallbackProperties');
set(h, 'MouseClickedCallback', @mouseFcn);

% callback
function mouseFcn(h, ~)
   fprintf('Item %g selected\n', h.getSelectedIndex+1);
   fprintf('Item(s) ');
   fprintf('%g ', h.getCheckBoxListSelectedIndices+1);
   fprintf('checked\n');
end
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Xiangrui Li		</title>
		<link>https://undocumentedmatlab.com/articles/checkboxlist#comment-365641</link>

		<dc:creator><![CDATA[Xiangrui Li]]></dc:creator>
		<pubDate>Wed, 30 Dec 2015 22:15:06 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5012#comment-365641</guid>

					<description><![CDATA[I was searching for checkbox list solution, and found this thread. Thanks Yair for providing different solutions! After playing with the options, here is my two cents. 

  (1) The MathWorks CheckBoxList looks nice, but as already asked here, I did not find a solution to add/remove an item. So it is not ideal for my purpose.
  (2) I did not try ActiveX method, since I want a system independent solution. 
  (3) The Matlab uitable method is very easy to use. I was trying to use it until I realize that there is no programmatic way to set the selected item. Another minor issue is that it seems there is no way to set alignment to left in case that the content exceeds the defined width. 

So I ended up the Matlab listbox method. I am sharing what I did with the listbox method, in case it is useful to others. It is almost the same as the the first method Yair described, but no java and image are used. Instead, I use two special characters for check and uncheck marks.

&lt;pre lang=&quot;matlab&quot;&gt; 
feature(&#039;DefaultCharacterSet&#039;, &#039;UTF-8&#039;); % needed for old matlab
checked = 9746; % square with X inside
unchecked = 9744; % empty square
h = uicontrol(&#039;Style&#039;, &#039;list&#039;, &#039;Position&#039;, [10 10 100 80], &#039;Callback&#039;, @select_cb, ...
    &#039;FontSize&#039;, 10, ... % affect the check mark coordinate detection
    &#039;String&#039;, {[checked &#039; First&#039;] [unchecked &#039; Second&#039;] [checked &#039; Third&#039;] [unchecked &#039; and last&#039;]});

function select_cb(h, ~)
i = get(h, &#039;Value&#039;);
x = get(0, &#039;PointerLocation&#039;); % figure CurrentPoint is not reliable
pos = get(gcf, &#039;Position&#039;) + get(h, &#039;Position&#039;);
x = x(1) - pos(1); % x coordinate of mouse click
if x&gt;2 &amp;&amp; x&lt;12 % related to FontSize, and maybe FontName
    str = get(h, &#039;String&#039;);
    if str{i}(1) ==  9746 % was checked
        str{i}(1) = 9744;
        fprintf(&#039;Item %g unchecked and selected.\n&#039;, i);
    else
        str{i}(1) = 9746;
        fprintf(&#039;Item %g checked and selected.\n&#039;, i);
    end
    set(h, &#039;String&#039;, str);
else
    fprintf(&#039;Item %g selected.\n&#039;, i);
end
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>I was searching for checkbox list solution, and found this thread. Thanks Yair for providing different solutions! After playing with the options, here is my two cents. </p>
<p>  (1) The MathWorks CheckBoxList looks nice, but as already asked here, I did not find a solution to add/remove an item. So it is not ideal for my purpose.<br />
  (2) I did not try ActiveX method, since I want a system independent solution.<br />
  (3) The Matlab uitable method is very easy to use. I was trying to use it until I realize that there is no programmatic way to set the selected item. Another minor issue is that it seems there is no way to set alignment to left in case that the content exceeds the defined width. </p>
<p>So I ended up the Matlab listbox method. I am sharing what I did with the listbox method, in case it is useful to others. It is almost the same as the the first method Yair described, but no java and image are used. Instead, I use two special characters for check and uncheck marks.</p>
<pre lang="matlab"> 
feature('DefaultCharacterSet', 'UTF-8'); % needed for old matlab
checked = 9746; % square with X inside
unchecked = 9744; % empty square
h = uicontrol('Style', 'list', 'Position', [10 10 100 80], 'Callback', @select_cb, ...
    'FontSize', 10, ... % affect the check mark coordinate detection
    'String', {[checked ' First'] [unchecked ' Second'] [checked ' Third'] [unchecked ' and last']});

function select_cb(h, ~)
i = get(h, 'Value');
x = get(0, 'PointerLocation'); % figure CurrentPoint is not reliable
pos = get(gcf, 'Position') + get(h, 'Position');
x = x(1) - pos(1); % x coordinate of mouse click
if x>2 &#038;& x&lt;12 % related to FontSize, and maybe FontName
    str = get(h, 'String');
    if str{i}(1) ==  9746 % was checked
        str{i}(1) = 9744;
        fprintf('Item %g unchecked and selected.\n', i);
    else
        str{i}(1) = 9746;
        fprintf('Item %g checked and selected.\n', i);
    end
    set(h, 'String', str);
else
    fprintf('Item %g selected.\n', i);
end
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/checkboxlist#comment-356721</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Thu, 10 Sep 2015 10:02:13 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5012#comment-356721</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/checkboxlist#comment-356705&quot;&gt;Loops&lt;/a&gt;.

@Loops - this is because of your uipanel (&lt;code&gt;hpanel&lt;/code&gt;). Instead, place your javacomponent directly within the figure, rather than a uipanel:
&lt;pre lang=&#039;matlab&#039;&gt;[jhScroll, hContainer] = javacomponent(jScrollPane, [2 2 60 80], hf);&lt;/pre&gt;

Alternatively, set your parent uipanel to have no border line:
&lt;pre lang=&#039;matlab&#039;&gt;hpanel = uipanel(&#039;Parent&#039;, hf, &#039;BorderType&#039;, &#039;none&#039;);&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/checkboxlist#comment-356705">Loops</a>.</p>
<p>@Loops &#8211; this is because of your uipanel (<code>hpanel</code>). Instead, place your javacomponent directly within the figure, rather than a uipanel:</p>
<pre lang='matlab'>[jhScroll, hContainer] = javacomponent(jScrollPane, [2 2 60 80], hf);</pre>
<p>Alternatively, set your parent uipanel to have no border line:</p>
<pre lang='matlab'>hpanel = uipanel('Parent', hf, 'BorderType', 'none');</pre>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
