<?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 2	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/customizing-menu-items-part-2/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-2?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=customizing-menu-items-part-2</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Thu, 28 Nov 2013 11:15:59 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>
		By: Thierry Dalon		</title>
		<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-2#comment-299866</link>

		<dc:creator><![CDATA[Thierry Dalon]]></dc:creator>
		<pubDate>Thu, 28 Nov 2013 11:15:59 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2902#comment-299866</guid>

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

sorry and thank you Yair for the prompt reply. I was using &lt;code&gt;JMenu.getItem&lt;/code&gt; instead of &lt;code&gt;jMenu.getMenuComponent&lt;/code&gt; as you advised. It works as you advise.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/customizing-menu-items-part-2#comment-299837">Yair Altman</a>.</p>
<p>sorry and thank you Yair for the prompt reply. I was using <code>JMenu.getItem</code> instead of <code>jMenu.getMenuComponent</code> as you advised. It works as you advise.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-2#comment-299837</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Thu, 28 Nov 2013 08:43:22 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2902#comment-299837</guid>

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

@Thierry - you have looked at the incorrect javadoc: &lt;code&gt;JMenu&lt;/code&gt; is the top-level menu (File/Edit/View/... - the &lt;code&gt;jFileMenu&lt;/code&gt; item in my article above) and for that you cannot set an accelerator - it is automatically set by the operating system, e.g. &#060;Alt&#062;-F to activate the File main menu.

However, accelerators work just fine for menu items that are not top-level (&lt;code&gt;JMenuItem&lt;/code&gt;, or rather &lt;code&gt;com.mathworks.mwswing.MJCheckBoxMenuItem&lt;/code&gt; which extends it). If you try the code you&#039;ll see that it works just fine. The relevant javadoc for these menu items is: &lt;a href=&quot;http://docs.oracle.com/javase/7/docs/api/javax/swing/JMenuItem.html#setAccelerator(javax.swing.KeyStroke)&quot; rel=&quot;nofollow&quot;&gt;http://docs.oracle.com/javase/7/docs/api/javax/swing/JMenuItem.html#setAccelerator(javax.swing.KeyStroke)&lt;/a&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/customizing-menu-items-part-2#comment-299835">Thierry Dalon</a>.</p>
<p>@Thierry &#8211; you have looked at the incorrect javadoc: <code>JMenu</code> is the top-level menu (File/Edit/View/&#8230; &#8211; the <code>jFileMenu</code> item in my article above) and for that you cannot set an accelerator &#8211; it is automatically set by the operating system, e.g. &lt;Alt&gt;-F to activate the File main menu.</p>
<p>However, accelerators work just fine for menu items that are not top-level (<code>JMenuItem</code>, or rather <code>com.mathworks.mwswing.MJCheckBoxMenuItem</code> which extends it). If you try the code you&#8217;ll see that it works just fine. The relevant javadoc for these menu items is: <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/JMenuItem.html#setAccelerator(javax.swing.KeyStroke)" rel="nofollow">http://docs.oracle.com/javase/7/docs/api/javax/swing/JMenuItem.html#setAccelerator(javax.swing.KeyStroke)</a></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Thierry Dalon		</title>
		<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-2#comment-299835</link>

		<dc:creator><![CDATA[Thierry Dalon]]></dc:creator>
		<pubDate>Thu, 28 Nov 2013 08:21:54 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2902#comment-299835</guid>

					<description><![CDATA[The &lt;i&gt;setAccelerator&lt;/i&gt; method throws an error:
&lt;a target=&quot;_blank&quot; href=&quot;http://docs.oracle.com/javase/7/docs/api/javax/swing/JMenu.html&quot; rel=&quot;nofollow&quot;&gt;http://docs.oracle.com/javase/7/docs/api/javax/swing/JMenu.html&lt;/a&gt;
&lt;pre&gt;
public void setAccelerator(KeyStroke keyStroke)
setAccelerator is not defined for JMenu. Use setMnemonic instead.
Overrides:
setAccelerator in class JMenuItem
Parameters:
keyStroke - the keystroke combination which will invoke the JMenuItem&#039;s actionlisteners without navigating the menu hierarchy
Throws:
Error - if invoked -- this method is not defined for JMenu. Use setMnemonic instead
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>The <i>setAccelerator</i> method throws an error:<br />
<a target="_blank" href="http://docs.oracle.com/javase/7/docs/api/javax/swing/JMenu.html" rel="nofollow">http://docs.oracle.com/javase/7/docs/api/javax/swing/JMenu.html</a></p>
<pre>
public void setAccelerator(KeyStroke keyStroke)
setAccelerator is not defined for JMenu. Use setMnemonic instead.
Overrides:
setAccelerator in class JMenuItem
Parameters:
keyStroke - the keystroke combination which will invoke the JMenuItem's actionlisteners without navigating the menu hierarchy
Throws:
Error - if invoked -- this method is not defined for JMenu. Use setMnemonic instead
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-2#comment-294364</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Mon, 11 Nov 2013 10:47:49 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2902#comment-294364</guid>

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

@Stephan - as far as I can tell, Matlab&#039;s context-menus are not implemented in Java and so they cannot be modified in the same manner. Instead of using Matlab&#039;s context menus, you can easily implement your own Java-based context-menu (which is much more customizable), as I have shown here: http://undocumentedmatlab.com/blog/setting-listbox-mouse-actions/]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/customizing-menu-items-part-2#comment-292893">Stephan Heise</a>.</p>
<p>@Stephan &#8211; as far as I can tell, Matlab&#8217;s context-menus are not implemented in Java and so they cannot be modified in the same manner. Instead of using Matlab&#8217;s context menus, you can easily implement your own Java-based context-menu (which is much more customizable), as I have shown here: <a href="http://undocumentedmatlab.com/blog/setting-listbox-mouse-actions/" rel="ugc">http://undocumentedmatlab.com/blog/setting-listbox-mouse-actions/</a></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Stephan Heise		</title>
		<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-2#comment-292893</link>

		<dc:creator><![CDATA[Stephan Heise]]></dc:creator>
		<pubDate>Thu, 07 Nov 2013 07:30:30 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2902#comment-292893</guid>

					<description><![CDATA[Oops - it seems as though most of my question got lost - sorry for that. Here it is again:


In your post you play with the main menu of the figure window. I would like to do similar stuff with a uicontextmenu (e.g. adding icons). However, I have so far been unsuccessful in finding the according Java reference for the context menu. Could you help me with that, please?]]></description>
			<content:encoded><![CDATA[<p>Oops &#8211; it seems as though most of my question got lost &#8211; sorry for that. Here it is again:</p>
<p>In your post you play with the main menu of the figure window. I would like to do similar stuff with a uicontextmenu (e.g. adding icons). However, I have so far been unsuccessful in finding the according Java reference for the context menu. Could you help me with that, please?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-2#comment-290608</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Wed, 30 Oct 2013 14:21:34 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2902#comment-290608</guid>

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

I don&#039;t understand your question...]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/customizing-menu-items-part-2#comment-290555">Stephan Heise</a>.</p>
<p>I don&#8217;t understand your question&#8230;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Stephan Heise		</title>
		<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-2#comment-290555</link>

		<dc:creator><![CDATA[Stephan Heise]]></dc:creator>
		<pubDate>Wed, 30 Oct 2013 12:18:27 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2902#comment-290555</guid>

					<description><![CDATA[Hi!

In your post you play with the figure window]]></description>
			<content:encoded><![CDATA[<p>Hi!</p>
<p>In your post you play with the figure window</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Roger Svensson		</title>
		<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-2#comment-244356</link>

		<dc:creator><![CDATA[Roger Svensson]]></dc:creator>
		<pubDate>Thu, 22 Aug 2013 16:01:09 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2902#comment-244356</guid>

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

Late answer but maybe useful for others with the same problem. Issue the following to close any open menus:
&lt;pre lang=&quot;matlab&quot;&gt;
javax.swing.MenuSelectionManager.defaultManager().clearSelectedPath();
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/customizing-menu-items-part-2#comment-129505">sebbo</a>.</p>
<p>Late answer but maybe useful for others with the same problem. Issue the following to close any open menus:</p>
<pre lang="matlab">
javax.swing.MenuSelectionManager.defaultManager().clearSelectedPath();
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: sebbo		</title>
		<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-2#comment-129505</link>

		<dc:creator><![CDATA[sebbo]]></dc:creator>
		<pubDate>Tue, 04 Dec 2012 12:30:50 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2902#comment-129505</guid>

					<description><![CDATA[Hi,

I&#039;m having trouble with the doClick-method...
I have no problem finding the menu and getting it to open with menu.doClick().
But it won&#039;t close on the next menu.doClick() call.

I already inserted drawnow&#039;s and pause(1) statements between the doClick-calls, but that doesn&#039;t help either - the menu simply remains open, even when I have a loop running à la:

&lt;pre lang=&quot;matlab&quot;&gt;
while true
    menu.doClick()
    pause(1);
end
&lt;/pre&gt;

Are there other ways to force the menu to hide again?]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>I&#8217;m having trouble with the doClick-method&#8230;<br />
I have no problem finding the menu and getting it to open with menu.doClick().<br />
But it won&#8217;t close on the next menu.doClick() call.</p>
<p>I already inserted drawnow&#8217;s and pause(1) statements between the doClick-calls, but that doesn&#8217;t help either &#8211; the menu simply remains open, even when I have a loop running à la:</p>
<pre lang="matlab">
while true
    menu.doClick()
    pause(1);
end
</pre>
<p>Are there other ways to force the menu to hide again?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/customizing-menu-items-part-2#comment-91512</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Wed, 20 Jun 2012 09:29:23 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=2902#comment-91512</guid>

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

@Attilio - Now you forgot to call doClick() as explained in the article. If you need any further customizations or help with your program please contact me via email (altmany at gmail).

In the future, please reply on the original comment thread, rather than creating a new thread.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/customizing-menu-items-part-2#comment-91508">Attilio Funel</a>.</p>
<p>@Attilio &#8211; Now you forgot to call doClick() as explained in the article. If you need any further customizations or help with your program please contact me via email (altmany at gmail).</p>
<p>In the future, please reply on the original comment thread, rather than creating a new thread.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
