<?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: Listbox layout customization	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/listbox-layout-customization/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/listbox-layout-customization?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=listbox-layout-customization</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Thu, 15 Aug 2019 20:54:06 +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/listbox-layout-customization#comment-491482</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Thu, 15 Aug 2019 20:54:06 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4374#comment-491482</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-490973&quot;&gt;Alex&lt;/a&gt;.

Alex - the reason is probably that when updating the &lt;b&gt;String&lt;/b&gt; property, the Matlab engine places a call to &lt;i&gt;setFixedCellHeight&lt;/i&gt; (or some other method that eventually sets the cell height) on the Event Dispatch (EDT queue), and this gets executed in a separate thread asynchronously, a few millisecs later. So if you directly call &lt;i&gt;setFixedCellHeight&lt;/i&gt; after setting &lt;b&gt;String&lt;/b&gt;, your call is being overridden by the EDT call a few millisecs later and only then the listbox gets repainted, so in the end you see no visible change. 
When you add a &lt;i&gt;&lt;b&gt;pause(0.01)&lt;/b&gt;&lt;/i&gt; before &lt;i&gt;setFixedCellHeight&lt;/i&gt;, the EDT call gets executed before your direct call, and so this does produce the requested effect, but due to the intervening listbox repaint you will necessarily see a flicker.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-490973">Alex</a>.</p>
<p>Alex &#8211; the reason is probably that when updating the <b>String</b> property, the Matlab engine places a call to <i>setFixedCellHeight</i> (or some other method that eventually sets the cell height) on the Event Dispatch (EDT queue), and this gets executed in a separate thread asynchronously, a few millisecs later. So if you directly call <i>setFixedCellHeight</i> after setting <b>String</b>, your call is being overridden by the EDT call a few millisecs later and only then the listbox gets repainted, so in the end you see no visible change.<br />
When you add a <i><b>pause(0.01)</b></i> before <i>setFixedCellHeight</i>, the EDT call gets executed before your direct call, and so this does produce the requested effect, but due to the intervening listbox repaint you will necessarily see a flicker.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Alex		</title>
		<link>https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-490973</link>

		<dc:creator><![CDATA[Alex]]></dc:creator>
		<pubDate>Mon, 12 Aug 2019 23:59:21 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4374#comment-490973</guid>

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

Hi Yair,
Thanks for your response. Annoyingly, and somewhat interestingly, a &lt;b&gt;&lt;i&gt;String&lt;/b&gt;&lt;/i&gt; update immediately followed by a &lt;i&gt;setFixedCellHeight&lt;/i&gt; means that the listbox does NOT update its height at all, if you call &lt;i&gt;getFixedCellHeight&lt;/i&gt; the value is still the default MATLAB value. I am not sure why this is.
One way to I found reduce to the flicker is adding a pause(0.01) before &lt;i&gt;setFixedCellHeight&lt;/i&gt; call, which does allow the cell height to be set, but it isn&#039;t much of a solution.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-464340">Sebastian</a>.</p>
<p>Hi Yair,<br />
Thanks for your response. Annoyingly, and somewhat interestingly, a <b><i>String</i></b> update immediately followed by a <i>setFixedCellHeight</i> means that the listbox does NOT update its height at all, if you call <i>getFixedCellHeight</i> the value is still the default MATLAB value. I am not sure why this is.<br />
One way to I found reduce to the flicker is adding a pause(0.01) before <i>setFixedCellHeight</i> call, which does allow the cell height to be set, but it isn&#8217;t much of a solution.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-490690</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Sun, 11 Aug 2019 08:50:37 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4374#comment-490690</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-490680&quot;&gt;Alex&lt;/a&gt;.

There is no simple solution. I think that if you call &lt;i&gt;setFixedCellHeight&lt;/i&gt; immediately after updating the &lt;b&gt;String&lt;/b&gt; property, without an intervening &lt;i&gt;&lt;b&gt;drawnow&lt;/b&gt;&lt;/i&gt; or &lt;i&gt;repaint&lt;/i&gt;, then there should be no flicker. The flicker indicates that one or both of &lt;i&gt;&lt;b&gt;drawnow&lt;/b&gt;&lt;/i&gt; or &lt;i&gt;repaint&lt;/i&gt; are being called between these two actions.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-490680">Alex</a>.</p>
<p>There is no simple solution. I think that if you call <i>setFixedCellHeight</i> immediately after updating the <b>String</b> property, without an intervening <i><b>drawnow</b></i> or <i>repaint</i>, then there should be no flicker. The flicker indicates that one or both of <i><b>drawnow</b></i> or <i>repaint</i> are being called between these two actions.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Alex		</title>
		<link>https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-490680</link>

		<dc:creator><![CDATA[Alex]]></dc:creator>
		<pubDate>Sun, 11 Aug 2019 07:49:20 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4374#comment-490680</guid>

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

Hi Yair,
I am having a similar issue to Sebastian, where cell height is reset when listbox.String is updated. I believe MATLAB redraws the listbox whenever the String field is updated, as it doesn&#039;t provide a &#039;addElement&#039; method. I can manually use &#039;setFixedCellHeight&#039; in callbacks following an update of the elements of the listbox, but the resize down to default and the resize back to the fixed height is clearly visible as a flicker, I am wondering if you have any suggestions in fixing this problem?

I tried using the addElement method of the DefaultListModel used in the listbox, but the ListModel is tied to updates in listbox.String field, rather than the other way around.

Many thanks,
Alex]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-464340">Sebastian</a>.</p>
<p>Hi Yair,<br />
I am having a similar issue to Sebastian, where cell height is reset when listbox.String is updated. I believe MATLAB redraws the listbox whenever the String field is updated, as it doesn&#8217;t provide a &#8216;addElement&#8217; method. I can manually use &#8216;setFixedCellHeight&#8217; in callbacks following an update of the elements of the listbox, but the resize down to default and the resize back to the fixed height is clearly visible as a flicker, I am wondering if you have any suggestions in fixing this problem?</p>
<p>I tried using the addElement method of the DefaultListModel used in the listbox, but the ListModel is tied to updates in listbox.String field, rather than the other way around.</p>
<p>Many thanks,<br />
Alex</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Alex		</title>
		<link>https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-490678</link>

		<dc:creator><![CDATA[Alex]]></dc:creator>
		<pubDate>Sun, 11 Aug 2019 07:39:18 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4374#comment-490678</guid>

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

Hi Yair,
I am having a similar issue with Sebastian, for my GUI, I need to add/remove elements to the listbox interactively, causing the cell height to be reverted. I believe this is because MATLAB doesn&#039;t have an addElement method for UIControls, meaning that the listbox needs to be redrawn everytime listbox.String is updated, resetting to the default MATLAB values for cell height and width. I can call &#039;setFixedCellHeight&#039; for every callback that changes the listbox, but this causes flickering and you can see the cells change size everytime it is updated, do you have any suggestions for avoiding this issue?

Thanks]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-464340">Sebastian</a>.</p>
<p>Hi Yair,<br />
I am having a similar issue with Sebastian, for my GUI, I need to add/remove elements to the listbox interactively, causing the cell height to be reverted. I believe this is because MATLAB doesn&#8217;t have an addElement method for UIControls, meaning that the listbox needs to be redrawn everytime listbox.String is updated, resetting to the default MATLAB values for cell height and width. I can call &#8216;setFixedCellHeight&#8217; for every callback that changes the listbox, but this causes flickering and you can see the cells change size everytime it is updated, do you have any suggestions for avoiding this issue?</p>
<p>Thanks</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Sebastian		</title>
		<link>https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-464794</link>

		<dc:creator><![CDATA[Sebastian]]></dc:creator>
		<pubDate>Thu, 28 Feb 2019 14:31:02 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4374#comment-464794</guid>

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

Oh all right. I thought I did something wrong and the settings should be consistent after repaints.

Also the &lt;code&gt;FontMetrics&lt;/code&gt; class works like a charm. Thanks a lot for your quick help!]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-464340">Sebastian</a>.</p>
<p>Oh all right. I thought I did something wrong and the settings should be consistent after repaints.</p>
<p>Also the <code>FontMetrics</code> class works like a charm. Thanks a lot for your quick help!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-464341</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Tue, 26 Feb 2019 12:53:04 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4374#comment-464341</guid>

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

The component is reset/repainted by Matlab when it determines that a component resize is required. You can trap this in the containing panel&#039;s &lt;b&gt;SizeChangedFcn&lt;/b&gt; or possibly the Java component&#039;s &lt;b&gt;ComponentResizedCallback&lt;/b&gt; callbacks, where you can reapply all the customizations.

Regarding the font size, you can use the Java &lt;code&gt;FontMetrics&lt;/code&gt; class to get the necessary information (&lt;a href=&quot;https://docs.oracle.com/javase/tutorial/2d/text/measuringtext.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;details&lt;/a&gt;)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-464340">Sebastian</a>.</p>
<p>The component is reset/repainted by Matlab when it determines that a component resize is required. You can trap this in the containing panel&#8217;s <b>SizeChangedFcn</b> or possibly the Java component&#8217;s <b>ComponentResizedCallback</b> callbacks, where you can reapply all the customizations.</p>
<p>Regarding the font size, you can use the Java <code>FontMetrics</code> class to get the necessary information (<a href="https://docs.oracle.com/javase/tutorial/2d/text/measuringtext.html" target="_blank" rel="nofollow">details</a>)</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Sebastian		</title>
		<link>https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-464340</link>

		<dc:creator><![CDATA[Sebastian]]></dc:creator>
		<pubDate>Tue, 26 Feb 2019 12:32:37 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4374#comment-464340</guid>

					<description><![CDATA[I have an issue here. I also use a Listbox with HTML code in it, and my figure resizes the listbox whenever the figure size is changed. Now it seems that the value set with &#039;setFixedCellHeight&#039; is reset after resizing. Do you have an idea why?

And something else: On a colleagues PC the HTML text is cut-off at the bottom. Now I found out that he is using a larger Windows font size. Do you have an idea how to detect the needed list item height depending on the used default font?

Best regards,
Sebastian]]></description>
			<content:encoded><![CDATA[<p>I have an issue here. I also use a Listbox with HTML code in it, and my figure resizes the listbox whenever the figure size is changed. Now it seems that the value set with &#8216;setFixedCellHeight&#8217; is reset after resizing. Do you have an idea why?</p>
<p>And something else: On a colleagues PC the HTML text is cut-off at the bottom. Now I found out that he is using a larger Windows font size. Do you have an idea how to detect the needed list item height depending on the used default font?</p>
<p>Best regards,<br />
Sebastian</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-320066</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Sat, 22 Mar 2014 22:37:22 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4374#comment-320066</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-320064&quot;&gt;Michael&lt;/a&gt;.

Of course you can do all that in Java (I don&#039;t know why you call it javax), it&#039;s called a JPopupMenu. But this is a Matlab blog, not a Java blog. So if you insist in using Java for this then I suggest that you check one of the numerous Java resources, either online or offline (books). You can start &lt;a href=&quot;http://docs.oracle.com/javase/tutorial/uiswing/components/menu.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-320064">Michael</a>.</p>
<p>Of course you can do all that in Java (I don&#8217;t know why you call it javax), it&#8217;s called a JPopupMenu. But this is a Matlab blog, not a Java blog. So if you insist in using Java for this then I suggest that you check one of the numerous Java resources, either online or offline (books). You can start <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/menu.html" target="_blank" rel="nofollow">here</a>.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Michael		</title>
		<link>https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-320064</link>

		<dc:creator><![CDATA[Michael]]></dc:creator>
		<pubDate>Sat, 22 Mar 2014 22:29:59 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4374#comment-320064</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-320043&quot;&gt;Yair Altman&lt;/a&gt;.

Hi Yair,
I&#039;m already using javax to customize the ListBox and other uicontrol .....is there any way to add popup menu and submenu with javax ? same for change listbox row color.

rgds,
Michael]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/listbox-layout-customization#comment-320043">Yair Altman</a>.</p>
<p>Hi Yair,<br />
I&#8217;m already using javax to customize the ListBox and other uicontrol &#8230;..is there any way to add popup menu and submenu with javax ? same for change listbox row color.</p>
<p>rgds,<br />
Michael</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
