<?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: Matlab callbacks for Java events in R2014a	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=matlab-callbacks-for-java-events-in-r2014a</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Fri, 03 Jan 2020 00:16:15 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-508081</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Fri, 03 Jan 2020 00:16:15 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4814#comment-508081</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-508080&quot;&gt;Neeks&lt;/a&gt;.

The &lt;a href=&quot;http://undocumentedmatlab.com/articles/javacomponent&quot;&gt;&lt;i&gt;&lt;b&gt;javacomponent&lt;/b&gt;&lt;/i&gt; function&lt;/a&gt; returns 2 objects: a Java reference and a Matlab container. Simply set the value of the &lt;b&gt;Units&lt;/b&gt; property of the Matlab container to &#039;normalized&#039;:
&lt;pre lang=&quot;matlab&quot;&gt;
[hjSlider, hContainer] = javacomponent(javax.swing.JSlider, pixelPosition, gcf);
hContainer.Units = &#039;normalized&#039;;
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-508080">Neeks</a>.</p>
<p>The <a href="http://undocumentedmatlab.com/articles/javacomponent"><i><b>javacomponent</b></i> function</a> returns 2 objects: a Java reference and a Matlab container. Simply set the value of the <b>Units</b> property of the Matlab container to &#8216;normalized&#8217;:</p>
<pre lang="matlab">
[hjSlider, hContainer] = javacomponent(javax.swing.JSlider, pixelPosition, gcf);
hContainer.Units = 'normalized';
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Neeks		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-508080</link>

		<dc:creator><![CDATA[Neeks]]></dc:creator>
		<pubDate>Thu, 02 Jan 2020 19:11:53 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4814#comment-508080</guid>

					<description><![CDATA[This looks elegant. Thank you. One issue I am not able to sort out - on maximizing the figure window the location of &quot;javax.swing.JSlider&quot; object does not scale properly?Is there a way to specify the &#039;Units&#039;,&#039;normalize&#039; property like we do in uicontrol() to maintain the scaling and location.]]></description>
			<content:encoded><![CDATA[<p>This looks elegant. Thank you. One issue I am not able to sort out &#8211; on maximizing the figure window the location of &#8220;javax.swing.JSlider&#8221; object does not scale properly?Is there a way to specify the &#8216;Units&#8217;,&#8217;normalize&#8217; property like we do in uicontrol() to maintain the scaling and location.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-399068</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Thu, 26 Jan 2017 08:27:21 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4814#comment-399068</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-399064&quot;&gt;Muthukumar&lt;/a&gt;.

You can either use the Java &lt;a href=&quot;http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;SimpleDateFormat&lt;/a&gt; class to convert the date format into your desired output format (read the Java docs online to see how to do this), or use Matlab&#039;s &lt;i&gt;&lt;b&gt;datenum&lt;/b&gt;&lt;/i&gt; and &lt;i&gt;&lt;b&gt;datestr&lt;/b&gt;&lt;/i&gt; functions with the appropriate format specifiers (read the corresponding Matlab docs to see how to do this).]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-399064">Muthukumar</a>.</p>
<p>You can either use the Java <a href="http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html" target="_blank" rel="nofollow">SimpleDateFormat</a> class to convert the date format into your desired output format (read the Java docs online to see how to do this), or use Matlab&#8217;s <i><b>datenum</b></i> and <i><b>datestr</b></i> functions with the appropriate format specifiers (read the corresponding Matlab docs to see how to do this).</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Muthukumar		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-399064</link>

		<dc:creator><![CDATA[Muthukumar]]></dc:creator>
		<pubDate>Thu, 26 Jan 2017 06:57:30 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4814#comment-399064</guid>

					<description><![CDATA[How do I get delimiter of the date format ?

example : 
system foramt - 1/23/2017 
Get Output from your script - mm dd,yyyy

I need output like - dd/mm/yyyy

Thanks in Advance]]></description>
			<content:encoded><![CDATA[<p>How do I get delimiter of the date format ?</p>
<p>example :<br />
system foramt &#8211; 1/23/2017<br />
Get Output from your script &#8211; mm dd,yyyy</p>
<p>I need output like &#8211; dd/mm/yyyy</p>
<p>Thanks in Advance</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-361419</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Thu, 12 Nov 2015 22:35:56 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4814#comment-361419</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-361412&quot;&gt;Matthew Harrison&lt;/a&gt;.

JAR files contain Java classes, not Matlab figures. The entire blog here discusses Matlab.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-361412">Matthew Harrison</a>.</p>
<p>JAR files contain Java classes, not Matlab figures. The entire blog here discusses Matlab.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Matthew Harrison		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-361412</link>

		<dc:creator><![CDATA[Matthew Harrison]]></dc:creator>
		<pubDate>Thu, 12 Nov 2015 21:50:35 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4814#comment-361412</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-361336&quot;&gt;Matthew Harrison&lt;/a&gt;.

Is there a clean way to do it from when your loading a .jar file?

For example I have a .jar file called test.jar
I call it like jFrame=test(); after adding it to the dynamic Java classpath
but that jFrame doesnt have properties to getWindow or JavaFrame?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-361336">Matthew Harrison</a>.</p>
<p>Is there a clean way to do it from when your loading a .jar file?</p>
<p>For example I have a .jar file called test.jar<br />
I call it like jFrame=test(); after adding it to the dynamic Java classpath<br />
but that jFrame doesnt have properties to getWindow or JavaFrame?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-361341</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Wed, 11 Nov 2015 19:37:01 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4814#comment-361341</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-361336&quot;&gt;Matthew Harrison&lt;/a&gt;.

&lt;pre lang=&#039;matlab&#039;&gt;
jFigPeer = get(handle(gcf),&#039;JavaFrame&#039;);
jFrame = handle(jFigPeer.fHG2Client.getWindow, &#039;CallbackProperties&#039;);
jFrame.WindowClosingCallback = @myCallback;
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-361336">Matthew Harrison</a>.</p>
<pre lang='matlab'>
jFigPeer = get(handle(gcf),'JavaFrame');
jFrame = handle(jFigPeer.fHG2Client.getWindow, 'CallbackProperties');
jFrame.WindowClosingCallback = @myCallback;
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Matthew Harrison		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-361336</link>

		<dc:creator><![CDATA[Matthew Harrison]]></dc:creator>
		<pubDate>Wed, 11 Nov 2015 17:30:53 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4814#comment-361336</guid>

					<description><![CDATA[Does anyone know how to get the window events like window closing using this method?]]></description>
			<content:encoded><![CDATA[<p>Does anyone know how to get the window events like window closing using this method?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Dave Brown		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-355803</link>

		<dc:creator><![CDATA[Dave Brown]]></dc:creator>
		<pubDate>Mon, 24 Aug 2015 17:49:57 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4814#comment-355803</guid>

					<description><![CDATA[I ran into a problem from using java 7 that took a while to discover so I thought I&#039;d share it.  Hopefully it helps those with the same problem in the future.

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;matlab&quot; style=&quot;font-family:monospace;&quot;&gt;&#062;&#062; jScrollbar = javaObjectEDT&lt;span style=&quot;color: #080;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A020F0;&quot;&gt;&#039;javax.swing.JScrollBar&#039;&lt;/span&gt;&lt;span style=&quot;color: #080;&quot;&gt;)&lt;/span&gt;;
&#062;&#062; hjScrollbar = handle&lt;span style=&quot;color: #080;&quot;&gt;(&lt;/span&gt;jScrollbar,&lt;span style=&quot;color:#A020F0;&quot;&gt;&#039;CallbackProperties&#039;&lt;/span&gt;&lt;span style=&quot;color: #080;&quot;&gt;)&lt;/span&gt;;
&#062;&#062; &lt;span style=&quot;color: #0000FF;&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color: #080;&quot;&gt;(&lt;/span&gt;hjScrollbar, &lt;span style=&quot;color:#A020F0;&quot;&gt;&#039;StateChangedCallback&#039;&lt;/span&gt;, callback&lt;span style=&quot;color: #080;&quot;&gt;)&lt;/span&gt;;
&lt;span style=&quot;color: #FF0000;&quot;&gt;Error using javahandle_withcallbacks.javax.swing.JScrollBar/set
The name &#039;StateChangedCallback&#039; is not an accessible property for an instance of class &#039;javax.swing.JScrollBar&#039;&lt;/span&gt;. 
&#160;
&#062;&#062; &lt;span style=&quot;color: #0000FF;&quot;&gt;ver&lt;/span&gt;
...
Java Version: Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
...&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

The problem is java 7 has changed the interface to the component and it is no longer a state change event but an adjustment event.  
(see http://www.java2s.com/Code/Java/Swing-JFC/ListeningforScrollbarValueChangesinaJScrollPaneContainer.htm).  It is corrected by using &lt;code&gt;hjScroll.AdjustmentValueChangedCallback&lt;/code&gt; in this example. Be on the lookout for these types of changes in the java interface.]]></description>
			<content:encoded><![CDATA[<p>I ran into a problem from using java 7 that took a while to discover so I thought I&#8217;d share it.  Hopefully it helps those with the same problem in the future.</p>
<div class="wp_syntax">
<div class="code">
<pre class="matlab" style="font-family:monospace;">&gt;&gt; jScrollbar = javaObjectEDT<span style="color: #080;">(</span><span style="color:#A020F0;">'javax.swing.JScrollBar'</span><span style="color: #080;">)</span>;
&gt;&gt; hjScrollbar = handle<span style="color: #080;">(</span>jScrollbar,<span style="color:#A020F0;">'CallbackProperties'</span><span style="color: #080;">)</span>;
&gt;&gt; <span style="color: #0000FF;">set</span><span style="color: #080;">(</span>hjScrollbar, <span style="color:#A020F0;">'StateChangedCallback'</span>, callback<span style="color: #080;">)</span>;
<span style="color: #FF0000;">Error using javahandle_withcallbacks.javax.swing.JScrollBar/set
The name 'StateChangedCallback' is not an accessible property for an instance of class 'javax.swing.JScrollBar'</span>. 
&nbsp;
&gt;&gt; <span style="color: #0000FF;">ver</span>
...
Java Version: Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
...</pre>
</div>
</div>
<p>The problem is java 7 has changed the interface to the component and it is no longer a state change event but an adjustment event.<br />
(see <a href="http://www.java2s.com/Code/Java/Swing-JFC/ListeningforScrollbarValueChangesinaJScrollPaneContainer.htm" rel="nofollow ugc">http://www.java2s.com/Code/Java/Swing-JFC/ListeningforScrollbarValueChangesinaJScrollPaneContainer.htm</a>).  It is corrected by using <code>hjScroll.AdjustmentValueChangedCallback</code> in this example. Be on the lookout for these types of changes in the java interface.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Danielle D		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-callbacks-for-java-events-in-r2014a#comment-343143</link>

		<dc:creator><![CDATA[Danielle D]]></dc:creator>
		<pubDate>Sat, 03 Jan 2015 21:59:56 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4814#comment-343143</guid>

					<description><![CDATA[Running Matlab 2014b, I had the same problem the Sean Lynch posted:

&lt;pre lang=&quot;matlab&quot;&gt;
&gt;&gt; h_evt = handle(evt, &#039;CallbackProperties&#039;);
&gt;&gt; set(h_evt,&#039;TestEventCallback&#039;,@(h,e)disp(h))
&gt;&gt; get(h_evt)
                    Class: [1x1 java.lang.Class]
        TestEventCallback: @(h,e)disp(h)
    TestEventCallbackData: []

&gt;&gt; evt.notifyMyTest
	javahandle_withcallbacks.EventTest
&lt;/pre&gt;

But trying something like
&lt;pre lang=&quot;matlab&quot;&gt;
&gt;&gt; set(h_evt,&#039;TestEventCallback&#039;,@(h,e)disp(&#039;test&#039;))
&gt;&gt; h_evt.notifyMyTest
test
&lt;/pre&gt;
demonstrates that it is working. One step at a time.

Thank you! This article helped a lot as well as the previous article: &lt;a href=&quot;http://undocumentedmatlab.com/blog/matlab-callbacks-for-java-events/&quot; rel=&quot;nofollow&quot;&gt;http://undocumentedmatlab.com/blog/matlab-callbacks-for-java-events/&lt;/a&gt;.]]></description>
			<content:encoded><![CDATA[<p>Running Matlab 2014b, I had the same problem the Sean Lynch posted:</p>
<pre lang="matlab">
>> h_evt = handle(evt, 'CallbackProperties');
>> set(h_evt,'TestEventCallback',@(h,e)disp(h))
>> get(h_evt)
                    Class: [1x1 java.lang.Class]
        TestEventCallback: @(h,e)disp(h)
    TestEventCallbackData: []

>> evt.notifyMyTest
	javahandle_withcallbacks.EventTest
</pre>
<p>But trying something like</p>
<pre lang="matlab">
>> set(h_evt,'TestEventCallback',@(h,e)disp('test'))
>> h_evt.notifyMyTest
test
</pre>
<p>demonstrates that it is working. One step at a time.</p>
<p>Thank you! This article helped a lot as well as the previous article: <a href="http://undocumentedmatlab.com/blog/matlab-callbacks-for-java-events/" rel="nofollow">http://undocumentedmatlab.com/blog/matlab-callbacks-for-java-events/</a>.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
