<?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: Tri-state checkbox	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/tri-state-checkbox/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/tri-state-checkbox?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tri-state-checkbox</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Mon, 15 Feb 2016 09:59:00 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>
		By: Dhanya Pradeep		</title>
		<link>https://undocumentedmatlab.com/articles/tri-state-checkbox#comment-369918</link>

		<dc:creator><![CDATA[Dhanya Pradeep]]></dc:creator>
		<pubDate>Mon, 15 Feb 2016 09:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2467#comment-369918</guid>

					<description><![CDATA[Hi Yair,
  I&#039;m trying to use the &lt;code&gt;com.mathworks.mwswing.checkboxtree&lt;/code&gt; in my MATLAB application. I&#039;m trying all sorts of methods for handling the actions on enabling and disabling the checkbox node. Unfortunately I&#039;m not getting the right callback to be used for handling the action based on the toggling of the checkbox. Could you give me some hint on the solution.

Thanks,
Dhanya]]></description>
			<content:encoded><![CDATA[<p>Hi Yair,<br />
  I&#8217;m trying to use the <code>com.mathworks.mwswing.checkboxtree</code> in my MATLAB application. I&#8217;m trying all sorts of methods for handling the actions on enabling and disabling the checkbox node. Unfortunately I&#8217;m not getting the right callback to be used for handling the action based on the toggling of the checkbox. Could you give me some hint on the solution.</p>
<p>Thanks,<br />
Dhanya</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/tri-state-checkbox#comment-134169</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Sun, 16 Dec 2012 17:56:35 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2467#comment-134169</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/tri-state-checkbox#comment-134140&quot;&gt;Pecus&lt;/a&gt;.

@Pecus - 

The possible &lt;code&gt;com.mathworks.mwswing.checkboxtree.SelectionState&lt;/code&gt; values are: &lt;code&gt;MIXED&lt;/code&gt;, &lt;code&gt;NOT_SELECTED&lt;/code&gt; and &lt;code&gt;SELECTED&lt;/code&gt;, which are pretty-much self-explanatory.

I assume that you are using GUIDE to create your GUI. In such a case, the *_OutputFcn() function is called after the entire GUI is created, immediately before the control is passed to the user. In this function, you have access to all handles. See &lt;a href=&quot;http://www.mathworks.com/help/matlab/creating_guis/initializing-a-guide-gui.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;this doc-page&lt;/a&gt;.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/tri-state-checkbox#comment-134140">Pecus</a>.</p>
<p>@Pecus &#8211; </p>
<p>The possible <code>com.mathworks.mwswing.checkboxtree.SelectionState</code> values are: <code>MIXED</code>, <code>NOT_SELECTED</code> and <code>SELECTED</code>, which are pretty-much self-explanatory.</p>
<p>I assume that you are using GUIDE to create your GUI. In such a case, the *_OutputFcn() function is called after the entire GUI is created, immediately before the control is passed to the user. In this function, you have access to all handles. See <a href="http://www.mathworks.com/help/matlab/creating_guis/initializing-a-guide-gui.html" target="_blank" rel="nofollow">this doc-page</a>.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Pecus		</title>
		<link>https://undocumentedmatlab.com/articles/tri-state-checkbox#comment-134140</link>

		<dc:creator><![CDATA[Pecus]]></dc:creator>
		<pubDate>Sun, 16 Dec 2012 16:18:53 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2467#comment-134140</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/tri-state-checkbox#comment-62288&quot;&gt;weiliang&lt;/a&gt;.

@Yair - Thanks for all the advice here! Just discovering all these mysteries...

I&#039;m having difficulties (probably the same as weilang had) disabling the mixed state of JCheckBox. If it has not been in mixed state, then I can toggle its state and appeareance (selected or deselected) by clicking. But soon as I put it in mixed state, changing the state by clicking does not affect its appeareance.
Also I could not find the method for setting the state of JCheckBox to selected/deselected. For MWCheckbox it is &quot;jCB.setSelected(1)&quot; (or &quot;0&quot;).
To put it in a nutshell:
1. What is the opposite of &quot;jCB.putClientProperty(&#039;selectionState&#039;, SelectionState.MIXED);&quot;?
2. What is the counterpart of &quot;jCB.setSelected(1)&quot;?

Third problem: I wrote a Callback function to switch on or off all subordinated checkboxes, if my JCheckBox has been clicked: (Still only works when not in mixed mode.)
&lt;pre lang=&#039;matlab&#039;&gt;
function Tristatecheckbox_Callback(hObject,eventdata,subCBs) % subCBs as CELL
isSelected=hObject.isSelected;
n=size(subCBs);
for i=1:n(2)
   set(subCBs{i},&#039;Value&#039;,isSelected);
end
&lt;/pre&gt;
Now my problem is where/when to associate this function with Java Callbacks.
I wrote this code snippet, which is working:
&lt;pre lang=&quot;matlab&quot;&gt;
hjCB = handle(handles.jCB,&#039;CallbackProperties&#039;); % initialised with &quot;handles.jCB = javax.swing.JCheckBox(...&quot;
subCBs={handles.CB1,handles.CB2,handles.CB3};
set(hjCB,&#039;ItemStateChangedCallback&#039;,{@Tristatecheckbox_Callback,subCBs});
&lt;/pre&gt;
First I put it right after the JCheckBox&#039;s creation, which is in the CreateFcn of a panel. But in CreateFcns there are no visible handles but those of the object in creation, so handles.CB1 can not be allocated.
For trial&#038;error, I put it in the CallbackFcn of a dummy pushbutton and just clicked this dummy before using the rest, but later I need this snippet to be done before the user can do anything with the GUI.
3. Is there a function running right after the GUI is created, with access to all the handles? Which one? And if no, where else to put the code?

Thanks a lot!]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/tri-state-checkbox#comment-62288">weiliang</a>.</p>
<p>@Yair &#8211; Thanks for all the advice here! Just discovering all these mysteries&#8230;</p>
<p>I&#8217;m having difficulties (probably the same as weilang had) disabling the mixed state of JCheckBox. If it has not been in mixed state, then I can toggle its state and appeareance (selected or deselected) by clicking. But soon as I put it in mixed state, changing the state by clicking does not affect its appeareance.<br />
Also I could not find the method for setting the state of JCheckBox to selected/deselected. For MWCheckbox it is &#8220;jCB.setSelected(1)&#8221; (or &#8220;0&#8221;).<br />
To put it in a nutshell:<br />
1. What is the opposite of &#8220;jCB.putClientProperty(&#8216;selectionState&#8217;, SelectionState.MIXED);&#8221;?<br />
2. What is the counterpart of &#8220;jCB.setSelected(1)&#8221;?</p>
<p>Third problem: I wrote a Callback function to switch on or off all subordinated checkboxes, if my JCheckBox has been clicked: (Still only works when not in mixed mode.)</p>
<pre lang='matlab'>
function Tristatecheckbox_Callback(hObject,eventdata,subCBs) % subCBs as CELL
isSelected=hObject.isSelected;
n=size(subCBs);
for i=1:n(2)
   set(subCBs{i},'Value',isSelected);
end
</pre>
<p>Now my problem is where/when to associate this function with Java Callbacks.<br />
I wrote this code snippet, which is working:</p>
<pre lang="matlab">
hjCB = handle(handles.jCB,'CallbackProperties'); % initialised with "handles.jCB = javax.swing.JCheckBox(..."
subCBs={handles.CB1,handles.CB2,handles.CB3};
set(hjCB,'ItemStateChangedCallback',{@Tristatecheckbox_Callback,subCBs});
</pre>
<p>First I put it right after the JCheckBox&#8217;s creation, which is in the CreateFcn of a panel. But in CreateFcns there are no visible handles but those of the object in creation, so handles.CB1 can not be allocated.<br />
For trial&amp;error, I put it in the CallbackFcn of a dummy pushbutton and just clicked this dummy before using the rest, but later I need this snippet to be done before the user can do anything with the GUI.<br />
3. Is there a function running right after the GUI is created, with access to all the handles? Which one? And if no, where else to put the code?</p>
<p>Thanks a lot!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/tri-state-checkbox#comment-62397</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Sat, 19 Nov 2011 16:04:38 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2467#comment-62397</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/tri-state-checkbox#comment-62288&quot;&gt;weiliang&lt;/a&gt;.

@weiliang - Java controls have some ~30 standard callbacks that you can set, ranging from mouse and keyboard events, through property and hierarchy changes, plus several callbacks that are specific to the control. Try setting the &lt;b&gt;StateChangedCallback&lt;/b&gt; and &lt;b&gt;ItemStateChangedCallback&lt;/b&gt;. More on Java component callbacks can be found &lt;a href=&quot;http://undocumentedmatlab.com/blog/uicontrol-callbacks/&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and in sections 3.4 and 6.4 of my &lt;a href=&quot;http://undocumentedmatlab.com-java-book/&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;Matlab-Java book&lt;/a&gt;.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/tri-state-checkbox#comment-62288">weiliang</a>.</p>
<p>@weiliang &#8211; Java controls have some ~30 standard callbacks that you can set, ranging from mouse and keyboard events, through property and hierarchy changes, plus several callbacks that are specific to the control. Try setting the <b>StateChangedCallback</b> and <b>ItemStateChangedCallback</b>. More on Java component callbacks can be found <a href="http://undocumentedmatlab.com/blog/uicontrol-callbacks/" target="_blank" rel="nofollow">here</a> and in sections 3.4 and 6.4 of my <a href="http://undocumentedmatlab.com-java-book/" target="_blank" rel="nofollow">Matlab-Java book</a>.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: weiliang		</title>
		<link>https://undocumentedmatlab.com/articles/tri-state-checkbox#comment-62288</link>

		<dc:creator><![CDATA[weiliang]]></dc:creator>
		<pubDate>Fri, 18 Nov 2011 19:20:36 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2467#comment-62288</guid>

					<description><![CDATA[I have tried all three approaches.
The first one, Modifying the standard Matlab checkbox uicontrol, has little change to my existing code, but the call to findjobj is too expansive and time consuming (i have more than 10 checkboxes).
Both Displaying as an independent Java control and Alternative controls will have no performance problem. but I have difficulty to add callbacks to the jCheckbox. 
Also all three seem have drawing problem when is in third state (partial check state).
Can someone comment on this. Code sample for how to add callback to the last two methods is greatly appreciated.]]></description>
			<content:encoded><![CDATA[<p>I have tried all three approaches.<br />
The first one, Modifying the standard Matlab checkbox uicontrol, has little change to my existing code, but the call to findjobj is too expansive and time consuming (i have more than 10 checkboxes).<br />
Both Displaying as an independent Java control and Alternative controls will have no performance problem. but I have difficulty to add callbacks to the jCheckbox.<br />
Also all three seem have drawing problem when is in third state (partial check state).<br />
Can someone comment on this. Code sample for how to add callback to the last two methods is greatly appreciated.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
