<?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: Common javacomponent problems	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/common-javacomponent-problems/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/common-javacomponent-problems?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=common-javacomponent-problems</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Sat, 29 Aug 2020 18:41:51 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>
		By: Collin		</title>
		<link>https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-508864</link>

		<dc:creator><![CDATA[Collin]]></dc:creator>
		<pubDate>Sat, 29 Aug 2020 18:41:51 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2607#comment-508864</guid>

					<description><![CDATA[Yair,

In 2020a Mathworks added this semi-useful class
&lt;code&gt;matlab.ui.internal.JavaMigrationTools&lt;/code&gt;
Which contains static methods to call javacomponent, actxcontrol or to get an object&#039;s JavaFrame or JavaContainer while suppressing the associated warning.]]></description>
			<content:encoded><![CDATA[<p>Yair,</p>
<p>In 2020a Mathworks added this semi-useful class<br />
<code>matlab.ui.internal.JavaMigrationTools</code><br />
Which contains static methods to call javacomponent, actxcontrol or to get an object&#8217;s JavaFrame or JavaContainer while suppressing the associated warning.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Melec		</title>
		<link>https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-374830</link>

		<dc:creator><![CDATA[Melec]]></dc:creator>
		<pubDate>Fri, 22 Apr 2016 08:30:42 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2607#comment-374830</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-374786&quot;&gt;Melec&lt;/a&gt;.

@Yair - I noticed it get back to the previous state after some time or as soon as I put my cursor on the toolbar.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-374786">Melec</a>.</p>
<p>@Yair &#8211; I noticed it get back to the previous state after some time or as soon as I put my cursor on the toolbar.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Melec		</title>
		<link>https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-374829</link>

		<dc:creator><![CDATA[Melec]]></dc:creator>
		<pubDate>Fri, 22 Apr 2016 08:01:47 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2607#comment-374829</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-374786&quot;&gt;Melec&lt;/a&gt;.

@Yair - I tried youר solution but it set the jpanel to the size of the matlab container and I want the jpanel to fit the jscrollpane.
I found a way to force the jpanel to fit to the jscrollpane :

&lt;pre lang=&quot;matlab&quot;&gt;
jpanel.setSize(jscrollpane.getSize)
 &lt;/pre&gt;

but it only last for some time and then get back automatically to the previous state. Do you know why?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-374786">Melec</a>.</p>
<p>@Yair &#8211; I tried youר solution but it set the jpanel to the size of the matlab container and I want the jpanel to fit the jscrollpane.<br />
I found a way to force the jpanel to fit to the jscrollpane :</p>
<pre lang="matlab">
jpanel.setSize(jscrollpane.getSize)
 </pre>
<p>but it only last for some time and then get back automatically to the previous state. Do you know why?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-374790</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Thu, 21 Apr 2016 13:47:31 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2607#comment-374790</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-374786&quot;&gt;Melec&lt;/a&gt;.

@Melec - you could try to use normalized units in the container handle that is returned as the second output arg by &lt;i&gt;&lt;b&gt;javacomponent&lt;/b&gt;&lt;/i&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-374786">Melec</a>.</p>
<p>@Melec &#8211; you could try to use normalized units in the container handle that is returned as the second output arg by <i><b>javacomponent</b></i></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Melec		</title>
		<link>https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-374786</link>

		<dc:creator><![CDATA[Melec]]></dc:creator>
		<pubDate>Thu, 21 Apr 2016 13:02:25 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2607#comment-374786</guid>

					<description><![CDATA[Hi,

I am trying to add a JTable (which has a number of rows that can change) into a Matlab interface. To do so I put the JTable into a JScrollPane which I draw in my interface through the javacomponent function. The problem is that I can&#039;t find a way to get the right size to assign in the javacomponent function.

I tried to use the preferrable size of the jtable or the preferrable size of the jscrolpane but it is never perfect. Either the table doesn&#039;t fit the all jscrollpane and there is a small band below the table or the jscrollpane is too small.

Then I tried to put the jscrollpane into a JPanel which fixed the table to fit the jscrollpane size. But then the panel is bigger than the table which is OK but its margins change according to the number of rows.

Does it exist a clean way to get the right size to apply in the javacomponent function?]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>I am trying to add a JTable (which has a number of rows that can change) into a Matlab interface. To do so I put the JTable into a JScrollPane which I draw in my interface through the javacomponent function. The problem is that I can&#8217;t find a way to get the right size to assign in the javacomponent function.</p>
<p>I tried to use the preferrable size of the jtable or the preferrable size of the jscrolpane but it is never perfect. Either the table doesn&#8217;t fit the all jscrollpane and there is a small band below the table or the jscrollpane is too small.</p>
<p>Then I tried to put the jscrollpane into a JPanel which fixed the table to fit the jscrollpane size. But then the panel is bigger than the table which is OK but its margins change according to the number of rows.</p>
<p>Does it exist a clean way to get the right size to apply in the javacomponent function?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-360503</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Tue, 03 Nov 2015 09:11:20 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2607#comment-360503</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-360500&quot;&gt;Amir G.&lt;/a&gt;.

The version that I uploaded to FEX yesterday included panel, uipanel, tab and uitab as newly acceptable parents.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-360500">Amir G.</a>.</p>
<p>The version that I uploaded to FEX yesterday included panel, uipanel, tab and uitab as newly acceptable parents.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Amir G.		</title>
		<link>https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-360500</link>

		<dc:creator><![CDATA[Amir G.]]></dc:creator>
		<pubDate>Tue, 03 Nov 2015 08:40:36 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2607#comment-360500</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-360433&quot;&gt;Amir G.&lt;/a&gt;.

@Yair - the &#039;regexprep&#039; function returns &#039;panel&#039; string for the &#039;uipanel&#039; class. so when I write &#039;panel&#039; I actually mean &#039;uipanel&#039;.
But I agree it should be tested for all possible use cases that was added since April-2007 release.

I&#039;ll try doing so and update, so &#039;uicomponent&#039; source in Mathworks can be updated/expanded for new versions of matlab.

Thanks]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-360433">Amir G.</a>.</p>
<p>@Yair &#8211; the &#8216;regexprep&#8217; function returns &#8216;panel&#8217; string for the &#8216;uipanel&#8217; class. so when I write &#8216;panel&#8217; I actually mean &#8216;uipanel&#8217;.<br />
But I agree it should be tested for all possible use cases that was added since April-2007 release.</p>
<p>I&#8217;ll try doing so and update, so &#8216;uicomponent&#8217; source in Mathworks can be updated/expanded for new versions of matlab.</p>
<p>Thanks</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-360438</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Mon, 02 Nov 2015 15:52:51 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2607#comment-360438</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-360437&quot;&gt;Yair Altman&lt;/a&gt;.

...and I would also add &lt;code&gt;&#039;tab&#039;&lt;/code&gt; and &lt;code&gt;&#039;uitab&#039;&lt;/code&gt; to this list, by the way...]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-360437">Yair Altman</a>.</p>
<p>&#8230;and I would also add <code>'tab'</code> and <code>'uitab'</code> to this list, by the way&#8230;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-360437</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Mon, 02 Nov 2015 15:40:46 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2607#comment-360437</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-360433&quot;&gt;Amir G.&lt;/a&gt;.

@Amir - when &lt;i&gt;&lt;b&gt;uicomponent&lt;/b&gt;&lt;/i&gt; was first created 8 years ago (April 2007), I do not think that panels were accepted as &lt;i&gt;&lt;b&gt;javacomponent&lt;/b&gt;&lt;/i&gt; parents, so the code was probably correct for the Matlab release at that time. I&#039;m not sure when exactly panels were added as legitimate &lt;i&gt;&lt;b&gt;javacomponent&lt;/b&gt;&lt;/i&gt; parents, but since that release your fix is good, except that it should also test for &lt;code&gt;&#039;uipanel&#039;&lt;/code&gt; (HG1), not just for &lt;code&gt;&#039;panel&#039;&lt;/code&gt; (HG2).]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-360433">Amir G.</a>.</p>
<p>@Amir &#8211; when <i><b>uicomponent</b></i> was first created 8 years ago (April 2007), I do not think that panels were accepted as <i><b>javacomponent</b></i> parents, so the code was probably correct for the Matlab release at that time. I&#8217;m not sure when exactly panels were added as legitimate <i><b>javacomponent</b></i> parents, but since that release your fix is good, except that it should also test for <code>'uipanel'</code> (HG1), not just for <code>'panel'</code> (HG2).</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Amir G.		</title>
		<link>https://undocumentedmatlab.com/articles/common-javacomponent-problems#comment-360433</link>

		<dc:creator><![CDATA[Amir G.]]></dc:creator>
		<pubDate>Mon, 02 Nov 2015 15:29:33 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2607#comment-360433</guid>

					<description><![CDATA[Hi Yair,

I&#039;ve looked deeper inside &quot;uicomponent&quot; function and I think I found a bug which related to the &quot;hiding&quot; problem.
Inside &quot;uicomponent&quot; there is a function named &quot;getParent&quot; which suppose to check if parent is valid (figure / uipanel) and return the parent handle.
but the following lines in the end of the function overwrites the actual parent that was found, so parent is always the main figure so the javacomponent isn&#039;t auto hiding with tabs i.e.
&lt;pre lang=&quot;matlab&quot;&gt; 
        position = position + [parentPosition(1:2),0,0];  % pixel position relative to figure
        parent = ancestor(parent,&#039;figure&#039;);
&lt;/pre&gt;

I think the problem in line 470:
&lt;pre lang=&quot;matlab&quot;&gt; 
elseif ~any(strcmpi(regexprep(class(hParent),&#039;.*\.&#039;,&#039;&#039;),{&#039;figure&#039;,&#039;uicontainer&#039;,&#039;uiflowcontainer&#039;,&#039;uigridcontainer&#039;}))
&lt;/pre&gt;
should be:
&lt;pre lang=&quot;matlab&quot;&gt; 
elseif ~any(strcmpi(regexprep(class(hParent),&#039;.*\.&#039;,&#039;&#039;),{&#039;figure&#039;,&#039;uicontainer&#039;,&#039;uiflowcontainer&#039;,&#039;uigridcontainer&#039;,&#039;panel&#039;}))
&lt;/pre&gt;

what do you think?]]></description>
			<content:encoded><![CDATA[<p>Hi Yair,</p>
<p>I&#8217;ve looked deeper inside &#8220;uicomponent&#8221; function and I think I found a bug which related to the &#8220;hiding&#8221; problem.<br />
Inside &#8220;uicomponent&#8221; there is a function named &#8220;getParent&#8221; which suppose to check if parent is valid (figure / uipanel) and return the parent handle.<br />
but the following lines in the end of the function overwrites the actual parent that was found, so parent is always the main figure so the javacomponent isn&#8217;t auto hiding with tabs i.e.</p>
<pre lang="matlab"> 
        position = position + [parentPosition(1:2),0,0];  % pixel position relative to figure
        parent = ancestor(parent,'figure');
</pre>
<p>I think the problem in line 470:</p>
<pre lang="matlab"> 
elseif ~any(strcmpi(regexprep(class(hParent),'.*\.',''),{'figure','uicontainer','uiflowcontainer','uigridcontainer'}))
</pre>
<p>should be:</p>
<pre lang="matlab"> 
elseif ~any(strcmpi(regexprep(class(hParent),'.*\.',''),{'figure','uicontainer','uiflowcontainer','uigridcontainer','panel'}))
</pre>
<p>what do you think?</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
