<?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: Customizing menu items part 3	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/customizing-menu-items-part-3/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-3?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=customizing-menu-items-part-3</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Tue, 29 Jan 2019 10:46:47 +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/customizing-menu-items-part-3#comment-458845</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Tue, 29 Jan 2019 10:46:47 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2909#comment-458845</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-458805&quot;&gt;Le Trong Nhan&lt;/a&gt;.

Using &lt;code&gt;RolloverIcon&lt;/code&gt; requires setting &lt;code&gt;RolloverEnabled&lt;/code&gt; to true (default=false):
&lt;pre lang=&quot;matlab&quot; highlight=&quot;1&quot;&gt;
jMenuItem.setRolloverEnabled(true);
jMenuItem.setRolloverIcon(icon1);
jMenuItem.setRolloverSelectedIcon(icon2);
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-458805">Le Trong Nhan</a>.</p>
<p>Using <code>RolloverIcon</code> requires setting <code>RolloverEnabled</code> to true (default=false):</p>
<pre lang="matlab" highlight="1">
jMenuItem.setRolloverEnabled(true);
jMenuItem.setRolloverIcon(icon1);
jMenuItem.setRolloverSelectedIcon(icon2);
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Le Trong Nhan		</title>
		<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-458805</link>

		<dc:creator><![CDATA[Le Trong Nhan]]></dc:creator>
		<pubDate>Tue, 29 Jan 2019 07:27:22 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2909#comment-458805</guid>

					<description><![CDATA[Hi Yair,
I am writing MATLAB with using Java in my program; And I use &lt;code&gt;RolloverIcon&lt;/code&gt; to set for my button with a image, but when I move mouse into button, my button does not show the image set. 
I need a advice from Mr. Yair !

Thanks]]></description>
			<content:encoded><![CDATA[<p>Hi Yair,<br />
I am writing MATLAB with using Java in my program; And I use <code>RolloverIcon</code> to set for my button with a image, but when I move mouse into button, my button does not show the image set.<br />
I need a advice from Mr. Yair !</p>
<p>Thanks</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-416101</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Mon, 06 Nov 2017 09:37:55 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2909#comment-416101</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-410878&quot;&gt;Sneha&lt;/a&gt;.

@Sneha - add a short &lt;code&gt;drawnow; pause(0.01)&lt;/code&gt; between the calls to &lt;code&gt;jFileMenu.doClick&lt;/code&gt; and the call to &lt;code&gt;jFileMenu.getMenuComponent&lt;/code&gt;. 

More information: 
  * &lt;a href=&quot;http://undocumentedmatlab.com/blog/matlab-and-the-event-dispatch-thread-edt&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://undocumentedmatlab.com/blog/matlab-and-the-event-dispatch-thread-edt&lt;/a&gt;
  * &lt;a href=&quot;http://undocumentedmatlab.com/blog/solving-a-matlab-hang-problem&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://undocumentedmatlab.com/blog/solving-a-matlab-hang-problem&lt;/a&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-410878">Sneha</a>.</p>
<p>@Sneha &#8211; add a short <code>drawnow; pause(0.01)</code> between the calls to <code>jFileMenu.doClick</code> and the call to <code>jFileMenu.getMenuComponent</code>. </p>
<p>More information:<br />
  * <a href="http://undocumentedmatlab.com/blog/matlab-and-the-event-dispatch-thread-edt" target="_blank" rel="nofollow">http://undocumentedmatlab.com/blog/matlab-and-the-event-dispatch-thread-edt</a><br />
  * <a href="http://undocumentedmatlab.com/blog/solving-a-matlab-hang-problem" target="_blank" rel="nofollow">http://undocumentedmatlab.com/blog/solving-a-matlab-hang-problem</a></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Sneha		</title>
		<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-410878</link>

		<dc:creator><![CDATA[Sneha]]></dc:creator>
		<pubDate>Wed, 26 Jul 2017 11:23:51 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2909#comment-410878</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-410555&quot;&gt;Sneha&lt;/a&gt;.

Hi Yair,
Apologies for my late reply. I did not attach the code previously sorry for that 
The below is the code written 
&lt;pre lang=&quot;matlab&quot;&gt;
jf = get(hObject,&#039;JavaFrame&#039;);
jmb = jf.fHG2Client.getMenuBar;
jFileMenu = jmb.getComponent(0);
jFileMenu.doClick;  %% open menu
jFileMenu.doClick; % close the menu
jvalue1 = jFileMenu.getMenuComponent(0);
jvalue2=jFileMenu.getMenuComponent(1);
jvalue3 = jFileMenu.getMenuComponent(2);
&lt;/pre&gt;
So this code if I execute line by line I am able to get tool tip messages but i run code as a .m file I gt that error]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-410555">Sneha</a>.</p>
<p>Hi Yair,<br />
Apologies for my late reply. I did not attach the code previously sorry for that<br />
The below is the code written </p>
<pre lang="matlab">
jf = get(hObject,'JavaFrame');
jmb = jf.fHG2Client.getMenuBar;
jFileMenu = jmb.getComponent(0);
jFileMenu.doClick;  %% open menu
jFileMenu.doClick; % close the menu
jvalue1 = jFileMenu.getMenuComponent(0);
jvalue2=jFileMenu.getMenuComponent(1);
jvalue3 = jFileMenu.getMenuComponent(2);
</pre>
<p>So this code if I execute line by line I am able to get tool tip messages but i run code as a .m file I gt that error</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-410556</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Thu, 20 Jul 2017 09:26:19 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2909#comment-410556</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-410555&quot;&gt;Sneha&lt;/a&gt;.

@Sneha - as I explained &lt;a href=&quot;http://undocumentedmatlab.com/blog/customizing-menu-items-part-2&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, the menu needs to be opened once in order for its menu items to become visible.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-410555">Sneha</a>.</p>
<p>@Sneha &#8211; as I explained <a href="http://undocumentedmatlab.com/blog/customizing-menu-items-part-2" target="_blank" rel="nofollow">here</a>, the menu needs to be opened once in order for its menu items to become visible.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Sneha		</title>
		<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-410555</link>

		<dc:creator><![CDATA[Sneha]]></dc:creator>
		<pubDate>Thu, 20 Jul 2017 09:11:38 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2909#comment-410555</guid>

					<description><![CDATA[Hi Yair,
The article is very helpful.
I tried  to execute the commands in a single m-file programatically but got an error.
The error occurred was 
&lt;pre lang=&quot;text&quot;&gt;
Java exception occurred:
java.lang.ArrayIndexOutOfBoundsException: No such child: 0
	at java.awt.Container.getComponent(Unknown Source)
	at javax.swing.JMenu.getMenuComponent(Unknown Source)
&lt;/pre&gt;

if I execute the code one line at a time I did not face any issue .
Could you please help me with the issue]]></description>
			<content:encoded><![CDATA[<p>Hi Yair,<br />
The article is very helpful.<br />
I tried  to execute the commands in a single m-file programatically but got an error.<br />
The error occurred was </p>
<pre lang="text">
Java exception occurred:
java.lang.ArrayIndexOutOfBoundsException: No such child: 0
	at java.awt.Container.getComponent(Unknown Source)
	at javax.swing.JMenu.getMenuComponent(Unknown Source)
</pre>
<p>if I execute the code one line at a time I did not face any issue .<br />
Could you please help me with the issue</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Ooms		</title>
		<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-371421</link>

		<dc:creator><![CDATA[Ooms]]></dc:creator>
		<pubDate>Wed, 09 Mar 2016 14:18:45 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2909#comment-371421</guid>

					<description><![CDATA[Hi Yair, 

I would like to make the labels editable in the menu itself. For example that you can richt-click on the word &#039;Save&#039;, a box pops up where you can select &#039;rename&#039;, and that the word &#039;Save&#039; becomes editable. maybe with an editbox style uicontrol at the exact location of the word &#039;Save&#039;. Is there a way to do this? What i do now is, i use an inputdlg box. But that is less userfriendly. Below is a function that shows and hides lines in a figure based on their displayname where i&#039;d like to use this.
&lt;pre lang=&quot;matlab&quot;&gt;
function showhide(h,a)
   f = findall(gcf,&#039;label&#039;,&#039;show/hide&#039;)
   if numel(f)
      s2=findall(f,&#039;position&#039;,2)
      if numel(s2)
         s2.Separator=&#039;on&#039;
      end
      if strcmp(h.Label,&#039;add&#039;)
         str = inputdlg(&#039;enter a string&#039;);
         uimenu(f,&#039;label&#039;,str{1},&#039;Callback&#039;,@showhide);
      else
         l = findall(gcf,&#039;type&#039;,&#039;line&#039;);
         c = char(setdiff({&#039;on&#039; &#039;off&#039;},get(h,&#039;checked&#039;)));
         set(h,&#039;Checked&#039;,c);
         set(l(~cellfun(&#039;isempty&#039;,strfind(get(l,&#039;DisplayName&#039;),h.Label))),&#039;visible&#039;,c,&#039;handlevisibility&#039;,c);
      end
   else
      f=uimenu(gcf,&#039;label&#039;,&#039;show/hide&#039;);
      uimenu(f,&#039;label&#039;,&#039;add&#039;,&#039;Callback&#039;,@showhide);
   end
end
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>Hi Yair, </p>
<p>I would like to make the labels editable in the menu itself. For example that you can richt-click on the word &#8216;Save&#8217;, a box pops up where you can select &#8216;rename&#8217;, and that the word &#8216;Save&#8217; becomes editable. maybe with an editbox style uicontrol at the exact location of the word &#8216;Save&#8217;. Is there a way to do this? What i do now is, i use an inputdlg box. But that is less userfriendly. Below is a function that shows and hides lines in a figure based on their displayname where i&#8217;d like to use this.</p>
<pre lang="matlab">
function showhide(h,a)
   f = findall(gcf,'label','show/hide')
   if numel(f)
      s2=findall(f,'position',2)
      if numel(s2)
         s2.Separator='on'
      end
      if strcmp(h.Label,'add')
         str = inputdlg('enter a string');
         uimenu(f,'label',str{1},'Callback',@showhide);
      else
         l = findall(gcf,'type','line');
         c = char(setdiff({'on' 'off'},get(h,'checked')));
         set(h,'Checked',c);
         set(l(~cellfun('isempty',strfind(get(l,'DisplayName'),h.Label))),'visible',c,'handlevisibility',c);
      end
   else
      f=uimenu(gcf,'label','show/hide');
      uimenu(f,'label','add','Callback',@showhide);
   end
end
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: amir		</title>
		<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-364911</link>

		<dc:creator><![CDATA[amir]]></dc:creator>
		<pubDate>Thu, 24 Dec 2015 17:29:52 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2909#comment-364911</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-115985&quot;&gt;Morteza&lt;/a&gt;.

i am amin from iran

maybe use pause ...it is possible]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-115985">Morteza</a>.</p>
<p>i am amin from iran</p>
<p>maybe use pause &#8230;it is possible</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: amir		</title>
		<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-364908</link>

		<dc:creator><![CDATA[amir]]></dc:creator>
		<pubDate>Thu, 24 Dec 2015 17:16:27 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2909#comment-364908</guid>

					<description><![CDATA[how can change oreintation menus and uitable  to right - left]]></description>
			<content:encoded><![CDATA[<p>how can change oreintation menus and uitable  to right &#8211; left</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-362049</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Fri, 20 Nov 2015 06:31:51 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2909#comment-362049</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-362034&quot;&gt;Adam Foltz&lt;/a&gt;.

@Adam - on some modern platforms, the menu items&#039; bgcolor is dynamically set by the system and cannot easily be overridden. In other words, 
&lt;pre lang=&#039;matlab&#039;&gt;jSave.setBackground(java.awt.Color.yellow)&lt;/pre&gt;
has no visible effect.

However, we can still use HTML/CSS, as follows:
&lt;pre lang=&#039;matlab&#039;&gt;
padding = [&#039; &amp;&#039; repmat(&#039;&#160;&#039;,1,30)];  % space padding to extend the background area
label = [&#039;&lt;html&gt;&lt;span style=&quot;background-color:yellow;&quot;&gt;Save&#039; padding]; 
jSave.setText(label)
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/customizing-menu-items-part-3#comment-362034">Adam Foltz</a>.</p>
<p>@Adam &#8211; on some modern platforms, the menu items&#8217; bgcolor is dynamically set by the system and cannot easily be overridden. In other words, </p>
<pre lang='matlab'>jSave.setBackground(java.awt.Color.yellow)</pre>
<p>has no visible effect.</p>
<p>However, we can still use HTML/CSS, as follows:</p>
<pre lang='matlab'>
padding = [' &#038;' repmat('&nbsp;',1,30)];  % space padding to extend the background area
label = ['<html><span style="background-color:yellow;">Save' padding]; 
jSave.setText(label)
</span></html></pre>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
