<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
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/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Undocumented Matlab &#187; JavaFrame</title> <atom:link href="http://undocumentedmatlab.com/blog/tag/javaframe/feed/" rel="self" type="application/rss+xml" /><link>http://undocumentedmatlab.com</link> <description>Charting Matlab's unsupported hidden underbelly</description> <lastBuildDate>Thu, 17 May 2012 12:01:26 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1.1</generator> <item><title>Customizing menu items part 3</title><link>http://undocumentedmatlab.com/blog/customizing-menu-items-part-3/</link> <comments>http://undocumentedmatlab.com/blog/customizing-menu-items-part-3/#comments</comments> <pubDate>Wed, 09 May 2012 18:00:05 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[GUI]]></category> <category><![CDATA[Icons]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[JavaFrame]]></category> <category><![CDATA[Menubar]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2909</guid> <description><![CDATA[Matlab menu items can easily display custom icons, using just a tiny bit of Java magic powder.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/customizing-menu-items-part-2/' rel='bookmark' title='Customizing menu items part 2'>Customizing menu items part 2</a> <small>Matlab menu items can be customized in a variety of useful ways using their underlying Java object. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/customizing-menu-items-part-1/' rel='bookmark' title='Customizing menu items part 1'>Customizing menu items part 1</a> <small>Matlab menus can be customized in a variety of undocumented manners - first article of a series. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/customizing-uitree-nodes/' rel='bookmark' title='Customizing uitree nodes &#8211; part 1'>Customizing uitree nodes &#8211; part 1</a> <small>This article describes how to customize specific nodes of Matlab GUI tree controls created using the undocumented uitree function...</small></li><li><a
href='http://undocumentedmatlab.com/blog/customizing-uitree-nodes-2/' rel='bookmark' title='Customizing uitree nodes &#8211; part 2'>Customizing uitree nodes &#8211; part 2</a> <small>This article shows how Matlab GUI tree nodes can be customized with checkboxes and similar controls...</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>In the past weeks I&#8217;ve shown how Matlab menus can be customized in a variety of undocumented manners, using HTML, <a
target="_blank" href="http://undocumentedmatlab.com/blog/customizing-menu-items-part-1/">pure Matlab</a>, and <a
target="_blank" href="http://undocumentedmatlab.com/blog/customizing-menu-items-part-2/">Java</a>. Today I conclude this mini-series with an article that explains how to use the underlying Java object to customize menu item icons. Menu customizations are explored in depth in section 4.6 of my <a
target="_blank" href="http://undocumentedmatlab.com/matlab-java-book/">book</a>.</p><h3 id="underlying">A reminder: accessing the underlying Java object</h3><p>Matlab menus (<i><b>uimenu</b></i>) are basically simple wrappers for the much more powerful and flexible Java Swing <a
target="_blank" rel="nofollow" href="http://docs.oracle.com/javase/tutorial/uiswing/components/menu.html"><code>JMenu</code> and <code>JMenuItem</code></a> on which they are based.  Many important functionalities that are available in Java menus are missing from the Matlab <i><b>uimenu</b></i>s.</p><p>Getting the Java reference for the figure window&#8217;s main menu is very easy:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jFrame = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span>hFig<span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">try</span>
    <span style="color: #228B22;">% R2008a and later</span>
    jMenuBar = jFrame.<span style="">fHG1Client</span>.<span style="">getMenuBar</span>;
<span style="color: #0000FF;">catch</span>
    <span style="color: #228B22;">% R2007b and earlier</span>
    jMenuBar = jFrame.<span style="">fFigureClient</span>.<span style="">getMenuBar</span>;
<span style="color: #0000FF;">end</span></pre></div></div><p>There are many customizations that can only be done using the Java handle: setting icons, several dozen callback types, tooltips, background color, font, text alignment, and so on. etc. Interested readers may wish to <i><b>get</b></i>/<i><b>set</b></i>/<i><b>inspect</b></i>/<i><b>methodsview</b></i>/<i><b><a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/17935-uiinspect-display-methods-properties-callbacks-of-an-object">uiinspect</a></b></i> the <code>jSave</code> reference handle and/or to read the documentation for <a
target="_blank" rel="nofollow" href="http://docs.oracle.com/javase/6/docs/api/javax/swing/JMenuItem.html"><code>JMenuItem</code></a>. Today&#8217;s article will focus on icon customizations.</p><h3 id="simple">Setting simple menu item icons</h3><p>Many of Matlab&#8217;s icons reside in either the <i>[matlabroot '/toolbox/matlab/icons/']</i> folder or the <i>[matlabroot '/java/jar/mwt.jar']</i> file (a JAR file is simply a zip file that includes Java classes and resources such as icon images). Let us create icons from the latter, to keep a consistent look-and-feel with the rest of Matlab (we could just as easily use our own external icon files):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% External icon file example</span>
jSave.<span style="">setIcon</span><span style="color: #080;">&#40;</span>javax.<span style="">swing</span>.<span style="">ImageIcon</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'C:\Yair\save.gif'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% JAR resource example</span>
jarFile = <span style="color: #0000FF;">fullfile</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">matlabroot</span>,<span style="color:#A020F0;">'/java/jar/mwt.jar'</span><span style="color: #080;">&#41;</span>;
iconsFolder = <span style="color:#A020F0;">'/com/mathworks/mwt/resources/'</span>;
iconURI = <span style="color: #080;">&#91;</span><span style="color:#A020F0;">'jar:file:/'</span> jarFile <span style="color:#A020F0;">'!'</span> iconsFolder <span style="color:#A020F0;">'save.gif'</span><span style="color: #080;">&#93;</span>;
iconURI = java.<span style="">net</span>.<span style="">URL</span><span style="color: #080;">&#40;</span>iconURI<span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% not necessary for external files</span>
jSave.<span style="">setIcon</span><span style="color: #080;">&#40;</span>javax.<span style="">swing</span>.<span style="">ImageIcon</span><span style="color: #080;">&#40;</span>iconURI<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Note that setting a menu item&#8217;s icon automatically re-aligns all other items in the menu, including those that do not have an icon (an internal bug that was introduced in R2010a causes a misalignment, as shown below):</p><p><center><div
class="wp-caption aligncenter" style="width: 240px"><img
alt="Menu item with a custom Icon (R2009b)" src="http://UndocumentedMatlab.com/images/uimenu3.png" title="Menu item with a custom Icon (R2009b)" width="230" height="120"/><p
class="wp-caption-text">Menu item with a custom <b>Icon</b> (R2009b)</p></div> &nbsp;&nbsp;&nbsp;<div
class="wp-caption aligncenter" style="width: 237px"><img
alt="...and the same in R2010a onward" src="http://UndocumentedMatlab.com/images/uimenu3b.png" title="...and the same in R2010a onward" width="227" height="120"/><p
class="wp-caption-text">...and the same in R2010a onward</p></div></center></p><h3 id="checkmark">Checkmark icon</h3><p>The empty space on the left of the menu is reserved for the check mark. Each Matlab menu item is check-able, since it is an object that extends the <code>com.mathworks.mwswing.MJCheckBoxMenuItem</code> class. I have not found a way to eliminate this empty space, which is really unnecessary in the File-menu case (it is only actually necessary in the View and Tools menus). Note that if an icon is set for the item, both the icon and the checkmark will be displayed, side by side.</p><p>The check mark is controlled by the <b>State</b> property of the Java object (which accepts logical true/false values), or the <b>Checked</b> property of the Matlab handle (which accepts the regular &#8216;on&#8217;/'off&#8217; string values):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Set the check mark at the Matlab level</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>findall<span style="color: #080;">&#40;</span>hFig,<span style="color:#A020F0;">'tag'</span>,<span style="color:#A020F0;">'figMenuFileSave'</span><span style="color: #080;">&#41;</span>, <span style="color:#A020F0;">'Checked'</span>,<span style="color:#A020F0;">'on'</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Equivalent - set the checkmark at the Java level</span>
jSave.<span style="">setState</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;</pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 195px"><img
alt="State = true, Icon = [ ]" src="http://UndocumentedMatlab.com/images/uimenu_save_checked1.png" title="State = true, Icon = [ ]" width="185" height="138"/><p
class="wp-caption-text"><b>State</b> = true, <b>Icon</b> = &#91; &#93;</p></div> &nbsp;&nbsp;&nbsp;<div
class="wp-caption aligncenter" style="width: 215px"><img
alt="State = true, Icon = custom" src="http://UndocumentedMatlab.com/images/uimenu_save_checked2.png" title="State = true, Icon = custom" width="205" height="137"/><p
class="wp-caption-text"><b>State</b> = true, <b>Icon</b> = custom</p></div></center></p><h3 id="custom">Customizing menu icons</h3><p>Icons can be customized: modify the gap between the icon and the label with the <b>IconTextGap</b> property (default = 4 [pixels]); place icons to the right of the label by setting <b>HorizontalTextPosition</b> to <code>jSave.LEFT</code> (=2), or centered using <code>jSave.CENTER</code> (=0). Note that the above-mentioned misalignment bug does not appear in these cases:</p><p><center><div
class="wp-caption aligncenter" style="width: 232px"><img
alt="jSave.setHorizontalTextPosition(jSave.LEFT)" src="http://UndocumentedMatlab.com/images/uimenu4.png" title="jSave.setHorizontalTextPosition(jSave.LEFT)" width="222" height="121"/><p
class="wp-caption-text"><code>jSave.setHorizontalTextPosition<br
/>(jSave.LEFT)</code></p></div> &nbsp;&nbsp;&nbsp;<div
class="wp-caption aligncenter" style="width: 233px"><img
alt="jSave.setHorizontalTextPosition(jSave.CENTER)" src="http://UndocumentedMatlab.com/images/uimenu5.png" title="jSave.setHorizontalTextPosition(jSave.CENTER)" width="223" height="120"/><p
class="wp-caption-text"><code>jSave.setHorizontalTextPosition<br
/>(jSave.CENTER)</code></p></div></center></p><p>Note how the label text can be seen through (or on top of) the icon when it is centered. This feature can be used to create stunning menu effects as shown below. Note how the width and height of the menu item automatically increased to accommodate my new 77&#215;31 icon size (icons are normally sized 16&#215;16 pixels):</p><p><center><div
class="wp-caption aligncenter" style="width: 295px"><img
alt="Overlaid icon (HorizontalTextPosition = CENTER)" src="http://UndocumentedMatlab.com/images/uimenu6.png" title="Overlaid icon (HorizontalTextPosition = CENTER)" width="285" height="136"/><p
class="wp-caption-text">Overlaid icon (<b>HorizontalTextPosition</b> = CENTER)</p></div></center></p><p>To resize an icon programmatically before setting it in a Java component, we can use the following example:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">myIcon = <span style="color: #0000FF;">fullfile</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">matlabroot</span>,<span style="color:#A020F0;">'/toolbox/matlab/icons/matlabicon.gif'</span><span style="color: #080;">&#41;</span>;
imageToolkit = java.<span style="">awt</span>.<span style="">Toolkit</span>.<span style="">getDefaultToolkit</span>;
iconImage = imageToolkit.<span style="">createImage</span><span style="color: #080;">&#40;</span>myIcon<span style="color: #080;">&#41;</span>;
iconImage = iconImage.<span style="">getScaledInstance</span><span style="color: #080;">&#40;</span><span style="color: #33f;">32</span>,<span style="color: #33f;">32</span>,iconImage.<span style="">SCALE_SMOOTH</span><span style="color: #080;">&#41;</span>;
jSave.<span style="">setIcon</span><span style="color: #080;">&#40;</span>javax.<span style="">swing</span>.<span style="">ImageIcon</span><span style="color: #080;">&#40;</span>iconImage<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Remember when rescaling images, particularly small ones with few pixels, that it is always better to shrink than to enlarge images: enlarging a small icon image might introduce a significant pixelization effect:</p><p><center><div
class="wp-caption aligncenter" style="width: 100px"><img
alt="16x16 icon image resized to 32x32" src="http://UndocumentedMatlab.com/images/button_icon2.png" title="16x16 icon image resized to 32x32" width="90" height="90"/><p
class="wp-caption-text">16x16 icon image resized to 32x32</p></div></center></p><p>Separate icons can be specified for a different appearance during mouse hover (<b>RolloverIcon</b>; requires <b>RolloverEnabled</b>=1), item click/press (<b>PressedIcon</b>), item selection (<b>SelectedIcon</b>, <b>RolloverSelectedIcon</b>, <b>DisabledSelectedIcon</b>), and disabled menu item (<b>DisabledIcon</b>). All these properties are empty ([]) by default, which applies a predefined default variation (image color filter) to the main item&#8217;s Icon. For example, let us modify <b>DisabledIcon</b>:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">myIcon = <span style="color:#A020F0;">'C:\Yair\Undocumented Matlab\Images\save_disabled.gif'</span>;
jSaveAs.<span style="">setDisabledIcon</span><span style="color: #080;">&#40;</span>javax.<span style="">swing</span>.<span style="">ImageIcon</span><span style="color: #080;">&#40;</span>myIcon<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
jSaveAs.<span style="">setEnabled</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>;</pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 130px"><img
alt="Enabled, main Icon" src="http://UndocumentedMatlab.com/images/uimenu7a.png" title="Enabled, main Icon" width="120" height="135"/><p
class="wp-caption-text">Enabled, main <b>Icon</b></p></div> &nbsp;&nbsp;&nbsp;<div
class="wp-caption aligncenter" style="width: 170px"><img
alt="Disabled, default Icon variation" src="http://UndocumentedMatlab.com/images/uimenu7b.png" title="Disabled, default Icon variation" width="120" height="135"/><p
class="wp-caption-text">Disabled, default <b>Icon</b> variation</p></div> &nbsp;&nbsp;&nbsp;<div
class="wp-caption aligncenter" style="width: 180px"><img
alt="Disabled, custom DisabledIcon" src="http://UndocumentedMatlab.com/images/uimenu7c.png" title="Disabled, custom DisabledIcon" width="120" height="135"/><p
class="wp-caption-text">Disabled, custom <b>DisabledIcon</b></p></div></center></p><p>Note the automatic graying of disabled menu items, including their icon. This effect can also be achieved programmatically using the static methods in <code>com.mathworks.mwswing.IconUtils</code>: <i>changeIconColor(), createBadgedIcon(), createGhostedIcon()</i>, and <i>createSelectedIcon()</i>. When we use a non-default custom <b>DisabledIcon</b>, it is used instead of the gray icon variant.</p><p>This concludes my mini-series of customizing menus in Matlab. If you have used any nifty customization that I have not mentioned, please post a comment about it <a
href="http://undocumentedmatlab.com/blog/customizing-menu-items-part-3/#respond">below</a>.</p><p><span
class="alignleft"><img
alt="Ken &#038; Mike" src="http://UndocumentedMatlab.com/images/ken_and_mike.png" title="Ken &#038; Mike" width="98" height="83"/></span>In an unrelated note, I would like to extend good wishes to Mike Katz, who has left the MathWorks mobile development team to join Kinvey a few days ago. Mike has been with MathWorks since 2005 and has been responsible for maintaining the official <a
target="_blank" rel="nofollow" href="http://blogs.mathworks.com/desktop/">MATLAB Desktop blog</a>, together with <a
target="_blank" href="http://undocumentedmatlab.com/blog/gui-integrated-browser-control/">Ken Orr</a>. I&#8217;m not sure yet which direction the Desktop blog will take, and by whom, but in any case it won&#8217;t be the same. You&#8217;re both missed, Mike &#038; Ken!</p><p
/>&nbsp;</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/customizing-menu-items-part-2/' rel='bookmark' title='Customizing menu items part 2'>Customizing menu items part 2</a> <small>Matlab menu items can be customized in a variety of useful ways using their underlying Java object. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/customizing-menu-items-part-1/' rel='bookmark' title='Customizing menu items part 1'>Customizing menu items part 1</a> <small>Matlab menus can be customized in a variety of undocumented manners - first article of a series. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/customizing-uitree-nodes/' rel='bookmark' title='Customizing uitree nodes &#8211; part 1'>Customizing uitree nodes &#8211; part 1</a> <small>This article describes how to customize specific nodes of Matlab GUI tree controls created using the undocumented uitree function...</small></li><li><a
href='http://undocumentedmatlab.com/blog/customizing-uitree-nodes-2/' rel='bookmark' title='Customizing uitree nodes &#8211; part 2'>Customizing uitree nodes &#8211; part 2</a> <small>This article shows how Matlab GUI tree nodes can be customized with checkboxes and similar controls...</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/customizing-menu-items-part-3/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Customizing menu items part 2</title><link>http://undocumentedmatlab.com/blog/customizing-menu-items-part-2/</link> <comments>http://undocumentedmatlab.com/blog/customizing-menu-items-part-2/#comments</comments> <pubDate>Wed, 02 May 2012 11:57:38 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[GUI]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[Callbacks]]></category> <category><![CDATA[JavaFrame]]></category> <category><![CDATA[Menubar]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2902</guid> <description><![CDATA[Matlab menu items can be customized in a variety of useful ways using their underlying Java object.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/customizing-menu-items-part-3/' rel='bookmark' title='Customizing menu items part 3'>Customizing menu items part 3</a> <small>Matlab menu items can easily display custom icons, using just a tiny bit of Java magic powder. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/customizing-menu-items-part-1/' rel='bookmark' title='Customizing menu items part 1'>Customizing menu items part 1</a> <small>Matlab menus can be customized in a variety of undocumented manners - first article of a series. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/customizing-workspace-context-menu/' rel='bookmark' title='Customizing Workspace context-menu'>Customizing Workspace context-menu</a> <small>Matlab's Workspace table context-menu can be configured with user-defined actions - this article explains how....</small></li><li><a
href='http://undocumentedmatlab.com/blog/customizing-uitree-nodes/' rel='bookmark' title='Customizing uitree nodes &#8211; part 1'>Customizing uitree nodes &#8211; part 1</a> <small>This article describes how to customize specific nodes of Matlab GUI tree controls created using the undocumented uitree function...</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>Last week I <a
target="_blank" href="http://undocumentedmatlab.com/blog/customizing-menu-items-part-1/">explained</a> how to customize Matlab&#8217;s menu items using some undocumented tricks that do not need Java. Today I will show how using just a tiny bit of Java magic powder we can add much more complex customizations to menu items. Menu customizations are explored in depth in section 4.6 of my <a
target="_blank" href="http://undocumentedmatlab.com/matlab-java-book/">book</a>.</p><h3 id="underlying">Accessing the underlying Java object</h3><p>Matlab menus (<i><b>uimenu</b></i>) are basically simple wrappers for the much more powerful and flexible Java Swing <a
target="_blank" rel="nofollow" href="http://docs.oracle.com/javase/tutorial/uiswing/components/menu.html"><code>JMenu</code> and <code>JMenuItem</code></a> on which they are based.  Many important functionalities that are available in Java menus are missing from the Matlab <i><b>uimenu</b></i>s.</p><p>Getting the Java reference for the figure window&#8217;s main menu is very easy:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jFrame = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span>hFig<span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">try</span>
    <span style="color: #228B22;">% R2008a and later</span>
    jMenuBar = jFrame.<span style="">fHG1Client</span>.<span style="">getMenuBar</span>;
<span style="color: #0000FF;">catch</span>
    <span style="color: #228B22;">% R2007b and earlier</span>
    jMenuBar = jFrame.<span style="">fFigureClient</span>.<span style="">getMenuBar</span>;
<span style="color: #0000FF;">end</span></pre></div></div><p>Note that we have used the figure handle&#8217;s hidden <a
target="_blank" href="http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/#JavaFrame"><b>JavaFrame</b> property</a>, accessed through the reference&#8217;s <i><b>handle</b></i>() wrapper, to prevent an annoying warning message.</p><p>There are many customizations that can only be done using the Java handle: setting icons, several dozen callback types, tooltips, background color, font, text alignment, and so on. etc. Interested readers may wish to <i><b>get</b></i>/<i><b>set</b></i>/<i><b>inspect</b></i>/<i><b>methodsview</b></i>/<i><b><a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/17935-uiinspect-display-methods-properties-callbacks-of-an-object">uiinspect</a></b></i> the <code>jSave</code> reference handle and/or to read the documentation for <a
target="_blank" rel="nofollow" href="http://docs.oracle.com/javase/6/docs/api/javax/swing/JMenuItem.html"><code>JMenuItem</code></a>. Some useful examples are provided below.</p><h3 id="dynamic">Dynamic menu behavior</h3><p>As a first example of Java-based customization, let us add DHTML-like behavior to the menu, such that the menu items will automatically be displayed when the mouse hovers over the item, without waiting for a user mouse click. First, get the <code>jMenuBar</code> reference as described above. Now, set the <b>MouseEnteredCallback</b> to automatically simulate a user mouse click on each menu item using its <i>doClick()</i> method. Setting the callback should be done separately to each of the top-level menu components:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">for</span> menuIdx = <span style="color: #33f;">1</span> <span style="color: #F0F;">:</span> jMenuBar.<span style="">getComponentCount</span>
    jMenu = jMenuBar.<span style="">getComponent</span><span style="color: #080;">&#40;</span>menuIdx-<span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>;
    hjMenu = handle<span style="color: #080;">&#40;</span>jMenu,<span style="color:#A020F0;">'CallbackProperties'</span><span style="color: #080;">&#41;</span>;
    <span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>hjMenu,<span style="color:#A020F0;">'MouseEnteredCallback'</span>,<span style="color:#A020F0;">'doClick(gcbo)'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">end</span></pre></div></div><p>Note that using this mechanism may be awkward if the top-level menu does not have a sub-menu but is rather a stand-alone menu item. For example, if the top-level menu-item &#8220;Help&#8221; is a stand-alone menu button (i.e., there are no help menu-items, just the single Help item), then moving the mouse over this item will trigger the help event, although the user did not actually click on the item. To prevent this behavior, we should modify the code snippet above to only work on those menu items that have sub-items.</p><h3 id="accelerator">Custom accelerator shortcut keys</h3><p>As another example, Matlab automatically assigns a non-modifiable keyboard accelerator key modifier of <ctrl>, while JMenus allow any combination of Alt/Ctrl/Shift/Meta (depending on the platform). Let us modify the default File/Save accelerator key from &#8216;Ctrl-S&#8217; to &#8216;Alt-Shift-S&#8217; as an example. We need a reference for the &#8220;Save&#8221; menu item. Note that unlike regular Java components, menu items are retrieved using the <i>getMenuComponent()</i> method and not <i>getComponent()</i>:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% File main menu is the first main menu item =&gt; index=0</span>
jFileMenu = jMenuBar.<span style="">getComponent</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Save menu item is the 5th menu item (separators included)</span>
jSave = jFileMenu.<span style="">getMenuComponent</span><span style="color: #080;">&#40;</span><span style="color: #33f;">4</span><span style="color: #080;">&#41;</span>; <span style="color: #228B22;">%Java indexes start with 0!</span>
inspect<span style="color: #080;">&#40;</span>jSave<span style="color: #080;">&#41;</span> 	<span style="color: #228B22;">% just to be sure: label='Save' =&gt; good!</span>
&nbsp;
<span style="color: #228B22;">% Finally, set a new accelerator key for this menu item:</span>
jAccelerator = javax.<span style="">swing</span>.<span style="">KeyStroke</span>.<span style="">getKeyStroke</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'alt shift S'</span><span style="color: #080;">&#41;</span>;
jSave.<span style="">setAccelerator</span><span style="color: #080;">&#40;</span>jAccelerator<span style="color: #080;">&#41;</span>;</pre></div></div><p>That is all there is to it – the label is modified automatically to reflect the new keyboard accelerator key. More info on setting different combinations of accelerator keys and modifiers can be found in the official Java documentation for <a
target="_blank" rel="nofollow" href="http://docs.oracle.com/javase/6/docs/api/javax/swing/KeyStroke.html#getKeyStroke%28java.lang.String%29"><code>KeyStroke</code></a>.</p><p><center><div
class="wp-caption aligncenter" style="width: 212px"><img
alt="Modification of menu item accelerator and tooltip" src="http://UndocumentedMatlab.com/images/uimenu1.png" title="Modification of menu item accelerator and tooltip" width="202" height="200"/><p
class="wp-caption-text">Modification of menu item accelerator and tooltip</p></div></center></p><p>Note that the Save menu-item reference can only be retrieved after opening the File menu at least once earlier; otherwise, an exception will be thrown when trying to access the menu item. The File menu does NOT need to remain open – it only needs to have been opened sometime earlier, for its menu items to be rendered. This can be done either interactively (by selecting the File menu) or programmatically:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Simulate mouse clicks to force the File main-menu to open &amp; close</span>
jFileMenu.<span style="">doClick</span>; <span style="color: #228B22;">% open the File menu</span>
jFileMenu.<span style="">doClick</span>; <span style="color: #228B22;">% close the menu</span>
&nbsp;
<span style="color: #228B22;">% Now the Save menu is accessible:</span>
jSave = jFileMenu.<span style="">getMenuComponent</span><span style="color: #080;">&#40;</span><span style="color: #33f;">4</span><span style="color: #080;">&#41;</span>;</pre></div></div><h3 id="tooltip">Tooltip and highlight</h3><p>For some unknown reason, MathWorks did not include a tooltip property in its Matlab menu handle, contrary to all the other Matlab GUI components. So we must use the Java handle, specifically the <b>ToolTipText</b> property:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jSave.<span style="">setToolTipText</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'modified menu item with tooltip'</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Java menu items also contain a property called <b>Armed</b>, which is a logical value (default=false). When turned on, the menu item is highlighted just as when it is selected (see the <i>Save As&#8230;</i> menu item in the screenshot above). On a Windows system, this means a blue background:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jSave.<span style="">setArmed</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>When the item is actually selected and then de-selected, <b>Armed</b> reverts to a false (off) value. Alternating the <b>Armed</b> property value can achieve an effect of flashing the menu item.</p><h3 id="callbacks">Callbacks</h3><p>In addition to the standard Swing control callbacks discussed in an <a
target="_blank" href="http://undocumentedmatlab.com/blog/uicontrol-callbacks/">earlier article</a>, menu items possess several additional callbacks that are specific to menu items, including:</p><ul><li><b>ActionPerformedCallback</b> – fired when the menu item is invoked</li><li><b>StateChangedCallback</b> – fired when the menu item is selected or deselected</li><li><b>MenuDragMouseXXXCallback</b> (XXX=Dragged/Entered/Exited/Released) – fired when the menu item is dragged, for the corresponding event</li><li><b>MenuKeyXXXCallback</b> (XXX=Pressed/Released/Typed) – fired when a keyboard click event occurs (the menu item&#8217;s accelerator was typed)</li></ul><p>Using these callbacks, together with the 30-odd standard Swing callbacks, we can control our menu&#8217;s behavior to a much higher degree than possible using the standard Matlab handle.</p><p>Next week, I will conclude this mini-series with an article explaining how to customize menu item icons.</ctrl></p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/customizing-menu-items-part-3/' rel='bookmark' title='Customizing menu items part 3'>Customizing menu items part 3</a> <small>Matlab menu items can easily display custom icons, using just a tiny bit of Java magic powder. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/customizing-menu-items-part-1/' rel='bookmark' title='Customizing menu items part 1'>Customizing menu items part 1</a> <small>Matlab menus can be customized in a variety of undocumented manners - first article of a series. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/customizing-workspace-context-menu/' rel='bookmark' title='Customizing Workspace context-menu'>Customizing Workspace context-menu</a> <small>Matlab's Workspace table context-menu can be configured with user-defined actions - this article explains how....</small></li><li><a
href='http://undocumentedmatlab.com/blog/customizing-uitree-nodes/' rel='bookmark' title='Customizing uitree nodes &#8211; part 1'>Customizing uitree nodes &#8211; part 1</a> <small>This article describes how to customize specific nodes of Matlab GUI tree controls created using the undocumented uitree function...</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/customizing-menu-items-part-2/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Docking figures in compiled applications</title><link>http://undocumentedmatlab.com/blog/docking-figures-in-compiled-applications/</link> <comments>http://undocumentedmatlab.com/blog/docking-figures-in-compiled-applications/#comments</comments> <pubDate>Wed, 15 Jun 2011 18:00:56 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Figure window]]></category> <category><![CDATA[High risk of breaking in future versions]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[Compiler]]></category> <category><![CDATA[Docking]]></category> <category><![CDATA[Figure]]></category> <category><![CDATA[JavaFrame]]></category> <category><![CDATA[Pure Matlab]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2341</guid> <description><![CDATA[Figures in compiled applications cannot officially be docked since R2008a, but this can be done using a simple undocumented trick.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/' rel='bookmark' title='Minimize/maximize figure window'>Minimize/maximize figure window</a> <small>Matlab figure windows can easily be maximized, minimized and restored using a bit of undocumented magic powder...</small></li><li><a
href='http://undocumentedmatlab.com/blog/findjobj-find-underlying-java-object/' rel='bookmark' title='FindJObj &#8211; find a Matlab component&#8217;s underlying Java object'>FindJObj &#8211; find a Matlab component&#8217;s underlying Java object</a> <small>The FindJObj utility can be used to access and display the internal components of Matlab controls and containers. This article explains its uses and inner mechanism....</small></li><li><a
href='http://undocumentedmatlab.com/blog/blurred-matlab-figure-window/' rel='bookmark' title='Blurred Matlab figure window'>Blurred Matlab figure window</a> <small>Matlab figure windows can be blurred using a semi-transparent overlaid window - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/jmi-wrapper-local-matlabcontrol-part-2/' rel='bookmark' title='JMI wrapper &#8211; local MatlabControl part 2'>JMI wrapper &#8211; local MatlabControl part 2</a> <small>An example using matlabcontrol for calling Matlab from within a Java class is explained and discussed...</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>Up until Matlab release R2008a, the Matlab compiler enabled compiled Matlab applications to have dockable figure windows, which docked into a &#8220;Figures&#8221; container. <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/support/solutions/en/data/1-A6XFET/">Starting with R2008a</a>, the compiler removed the figure&#8217;s docking capability and figures can no longer be docked.</p><p>Well, at least not officially <img
src='http://undocumentedmatlab.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p><p>The following trick restores the docking controls to figures in R2008a-compiled applications, enabling figure docking. Simply add one or both of the following alternatives in your application, after the figure has been created:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Alternative #1 - uses pure Matlab</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>hFig, <span style="color:#A020F0;">'DockControls'</span>, <span style="color:#A020F0;">'on'</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Alternative #2 - uses the underlying Java frame</span>
jFrame = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span>hFig<span style="color: #080;">&#41;</span>, <span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">try</span>
   <span style="color: #228B22;">% This works up to R2011a</span>
   jFrame.<span style="">fFigureClient</span>.<span style="">setClientDockable</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">catch</span>
   <span style="color: #228B22;">% This works from R2008b and up</span>
   jFrame.<span style="">fHG1Client</span>.<span style="">setClientDockable</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">end</span></pre></div></div><p>where <code>hFig</code> is the figure handle. This will have no effect for the regular interpreted (non-compiled) run of the application, where these controls are &#8216;on&#8217; by default. But in the compiled application, although it may erroneously report that the controls are &#8216;on&#8217;, they are in fact &#8216;off&#8217;, so turning them &#8216;on&#8217; fixes the problem.</p><p><center><div
class="wp-caption aligncenter" style="width: 478px"><img
alt="Matlab figure docking control" src="http://UndocumentedMatlab.com/images/dock4.png" title="Matlab figure docking control" width="468" /><p
class="wp-caption-text">Matlab figure docking control</p></div></center></p><p><u>Note</u>: the two variants in alternative #2 above are actually identical, it is simply that the relevant field name has changed: Up to R2008a, only the <code>fFigureClient</code> existed; in R2008b, the <code>fHG1Client</code> field was added, which was simply an alias for <code>fFigureClient</code>, holding the same reference handle, so either of these fields could be used (a corresponding fHG2Client was also added &#8211; more on HG1 and HG2 <a
target="_blank" href="http://undocumentedmatlab.com/blog/tag/hg2/">here</a>). In R2011b (at least the pre-release), the <code>fFigureClient</code> alias field was dropped and only <code>fHG1Client</code> remained. While the field name has changed, the underlying docking functionality appears to have remained stable over all these releases. For the record, in answer to a <a
href="http://undocumentedmatlab.com/blog/docking-figures-in-compiled-applications/#comment-48632">user question below</a>, these fields can be listed using the built in <i><b>fieldnames</b></i> function:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% R2008b - R2011a:</span>
&gt;&gt; <span style="color: #0000FF;">fieldnames</span><span style="color: #080;">&#40;</span>jFrame<span style="color: #080;">&#41;</span>
<span style="color: #0000FF;">ans</span> = 
    <span style="color:#A020F0;">'fFigureClient'</span>
    <span style="color:#A020F0;">'fHG2Client'</span>
    <span style="color:#A020F0;">'fHG1Client'</span>
    <span style="color:#A020F0;">'fUseHG2'</span>
    <span style="color:#A020F0;">'UICONTROLBACKGROUND_OS'</span>
    <span style="color:#A020F0;">'UICONTROLBACKGROUND_COMPATIBLE'</span></pre></div></div><p>I was reminded of this trick by <a
target="_blank" href="http://undocumentedmatlab.com/blog/tab-panels-uitab-and-relatives/#comment-47197">Aurélien&#8217;s recent comment</a>, where he mentions MathWorks so-called workaround for this problem, which (IMHO) is really not a work-around at all: MathWorks advises to modify our application to use &#8211; would you believe this &#8211; tabbed panels to &#8220;dock&#8221; the separate figures contents onto separate panels. Not to mention the fact that this so-called &#8220;solution&#8221; relies on undocumented and unsupported Matlab functionality (that of <a
target="_blank" href="http://undocumentedmatlab.com/blog/tab-panels-uitab-and-relatives/">tabbed-panels</a>) and requires major rework of existing applications, it also results in far inferior look-and-feel than simple docking as G-d intended&#8230;</p><p>Since I have demonstrated above that the docking functionality actually exists in compiled apps just as in the interpreted m-file apps, I do not understand why MathWorks took such great pains to prevent this important functionality in the compiler. There must be some important reason for this, but I cannot think of any. Perhaps if there is enough public demand, MathWorks will agree to return the docking functionality.</p><p>Unfortunately, I recently discovered that in the most recent compiler, that ships with R2011a, alternative #1 above (which uses pure Matlab) no longer works. Sometime between R2008a and R2011a MathWorks discovered my first back-door and closed it. Such a pity&#8230;</p><p>Luckily, alternative #2 (which uses the underlying Java frame object) seems to still work, even on R2011a.</p><p>I still haven&#8217;t tested this on R2011b&#8217;s compiler (whose pre-release has become available for download yesterday), but hopefully the trick above will continue to work on R2011b and on subsequent releases &#8211; please <a
href="http://undocumentedmatlab.com/blog/docking-figures-in-compiled-applications/#respond">tell me</a> if you find out otherwise.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/' rel='bookmark' title='Minimize/maximize figure window'>Minimize/maximize figure window</a> <small>Matlab figure windows can easily be maximized, minimized and restored using a bit of undocumented magic powder...</small></li><li><a
href='http://undocumentedmatlab.com/blog/findjobj-find-underlying-java-object/' rel='bookmark' title='FindJObj &#8211; find a Matlab component&#8217;s underlying Java object'>FindJObj &#8211; find a Matlab component&#8217;s underlying Java object</a> <small>The FindJObj utility can be used to access and display the internal components of Matlab controls and containers. This article explains its uses and inner mechanism....</small></li><li><a
href='http://undocumentedmatlab.com/blog/blurred-matlab-figure-window/' rel='bookmark' title='Blurred Matlab figure window'>Blurred Matlab figure window</a> <small>Matlab figure windows can be blurred using a semi-transparent overlaid window - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/jmi-wrapper-local-matlabcontrol-part-2/' rel='bookmark' title='JMI wrapper &#8211; local MatlabControl part 2'>JMI wrapper &#8211; local MatlabControl part 2</a> <small>An example using matlabcontrol for calling Matlab from within a Java class is explained and discussed...</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/docking-figures-in-compiled-applications/feed/</wfw:commentRss> <slash:comments>15</slash:comments> </item> <item><title>Minimize/maximize figure window</title><link>http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/</link> <comments>http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/#comments</comments> <pubDate>Wed, 18 May 2011 23:08:07 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Figure window]]></category> <category><![CDATA[GUI]]></category> <category><![CDATA[Hidden property]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[Undocumented function]]></category> <category><![CDATA[Donn Shull]]></category> <category><![CDATA[JavaFrame]]></category> <category><![CDATA[Undocumented property]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2310</guid> <description><![CDATA[Matlab figure windows can easily be maximized, minimized and restored using a bit of undocumented magic powder<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/disable-entire-figure-window/' rel='bookmark' title='Enable/disable entire figure window'>Enable/disable entire figure window</a> <small>Disabling/enabling an entire figure window is impossible with pure Matlab, but is very simple using the underlying Java. This article explains how....</small></li><li><a
href='http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/' rel='bookmark' title='Transparent Matlab figure window'>Transparent Matlab figure window</a> <small>Matlab figure windows can be made fully or partially transparent/translucent or blurred - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/blurred-matlab-figure-window/' rel='bookmark' title='Blurred Matlab figure window'>Blurred Matlab figure window</a> <small>Matlab figure windows can be blurred using a semi-transparent overlaid window - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/detecting-window-focus-events/' rel='bookmark' title='Detecting window focus events'>Detecting window focus events</a> <small>Matlab does not have any documented method to detect window focus events (gain/loss). This article describes an undocumented way to detect such events....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>Over the past couple of years, I posted <a
target="_blank" href="http://undocumentedmatlab.com/blog/tag/javaframe/">several articles</a> using the <b>JavaFrame</b> property of the figure handle, which enables access to the GUI&#8217;s underlying Java peer object. Today, I show how using <b>JavaFrame</b> we can solve a very frequent user request on the Matlab CSSM forum.</p><h3 id="Problem">The problem</h3><p>Matlab figures can be maximized, minimized and restored by <em>interactively</em> clicking the corresponding icon (or menu item) on the figure window&#8217;s frame (the title bar). However, we often need to create maximized main-application windows, and wish to save the users the need to manually maximize the window. Moreover, we may sometimes even wish to prevent users from resizing a maximized main window.</p><p>Unfortunately, Matlab does not contain any documented or supported way to <em>programmatically</em> maximize, minimize or restore a figure window.</p><p>This is very strange considering the fact that these are such elementary figure operations. Moreover, these operations are supported internally (and have been for many releases already), as shown below. It is therefore difficult for me to understand why they were not added to the documented Matlab HG wrapper functionality a long time ago. I fail to understand why obscure features such as docking were added to the wrapper, but standard minimization and maximization were not.</p><h3 id="Maximization">Maximization</h3><p><a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/?term=maximize+window">Several solutions</a> have been presented to this problem over the years. Let us start with the pressing question of figure maximization:</p><p>Solutions that rely on documented Matlab features tend to compute the available screen size and resize the figure accordingly. The result is lacking in many respects: it does not account for the taskbar (neither in size nor in location, which is not necessarily at the bottom of the screen); it does not remove the window border as in regular maximized figures; and it often ignores extended desktops (i.e. an attached additional monitor).</p><p>The solutions that do work properly all rely on undocumented features: Some use platform-specific native Windows API in a mex-file (Jan Simon&#8217;s recent <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/31437-windowapi">WindowAPI</a> submission really pushes the limit in this and other regards). Alternately, we can easily use the platform-independent <b>JavaFrame</b>:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; jFrame = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span>
jFrame =
com.<span style="">mathworks</span>.<span style="">hg</span>.<span style="">peer</span>.<span style="">FigurePeer</span>@cdbd96
&nbsp;
&gt;&gt; jFrame.<span style="">setMaximized</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;   <span style="color: #228B22;">% to maximize the figure</span>
&gt;&gt; jFrame.<span style="">setMaximized</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% to un-maximize the figure</span></pre></div></div><h3 id="Minimization">Minimization</h3><p>To the best of my knowledge, there are no solutions for minimizing figure windows that use documented Matlab features. Again, this can be done using either native Windows API, or the platform-independent <b>JavaFrame</b>:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; jFrame.<span style="">setMinimized</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;   <span style="color: #228B22;">% to minimize the figure</span>
&gt;&gt; jFrame.<span style="">setMinimized</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% to un-minimize the figure</span></pre></div></div><h3 id="Notes">Usage notes</h3><p><b>Maximized</b> and <b>Minimized</b> are mutually-exclusive, meaning that no more than one of them can be 1 (or true) at any time. This is automatically handled – users only need to be aware that a situation in which a window is both maximized and minimized at the same time is impossible (duh!).</p><p>There are several equivalent manners of setting <code>jFrame</code>&#8216;s <b>Maximized</b> and <b>Minimized</b> property values, and your choice may simply be a matter of aesthetics and personal taste:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Three alternative possibilities of setting Maximized:</span>
jFrame.<span style="">setMaximized</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>jFrame,<span style="color:#A020F0;">'Maximized'</span>,<span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;   <span style="color: #228B22;">% note interchangeable 1&lt; =&gt;true, 0&lt; =&gt;false</span>
jFrame.<span style="">handle</span>.<span style="">Maximized</span> = <span style="color: #33f;">1</span>;</pre></div></div><p><code>jFrame</code> follows Java convention: the accessor method that retrieves boolean values is called <i>is&lt;Propname&gt;()</i> instead of <i>get&lt;Propname&gt;</i>. In our case: <i>isMaximized()</i> and <i>isMinimized()</i>:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">flag</span> = jFrame.<span style="">isMinimized</span>;        <span style="color: #228B22;">% Note: isMinimized, not getMinimized</span>
<span style="color: #0000FF;">flag</span> = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>jFrame,<span style="color:#A020F0;">'Minimized'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">flag</span> = jFrame.<span style="">handle</span>.<span style="">Minimized</span>;</pre></div></div><p>In some old Matlab releases, <code>jFrame</code> did not possess the <b>Maximized</b> and <b>Minimized</b> properties, and their associated accessor methods. In this case, use the internal <code>FrameProxy</code> which has always contained them:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; jFrameProxy = jFrame.<span style="">fFigureClient</span>.<span style="">getWindow</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span> 
jFrameProxy =
com.<span style="">mathworks</span>.<span style="">hg</span>.<span style="">peer</span>.<span style="">FigureFrameProxy</span>$FigureFrame<span style="color: #080;">&#91;</span>fClientProxyFrame,<span style="color: #33f;">227</span>,<span style="color: #33f;">25</span>,568x502,invalid,layout=java.<span style="">awt</span>.<span style="">BorderLayout</span>,<span style="color: #0000FF;">title</span>=<span style="color: #0000FF;">Figure</span> <span style="color: #33f;">1</span>,resizable,normal,defaultCloseOperation=DO_NOTHING_ON_CLOSE,<span style="color: #F0F;">...</span><span style="color: #080;">&#93;</span>
&nbsp;
&gt;&gt; <span style="color: #228B22;">% Three alternative possibilities of setting Minimized:</span>
&gt;&gt; jFrameProxy.<span style="">setMinimized</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;
&gt;&gt; <span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>jFrameProxy,<span style="color:#A020F0;">'Minimized'</span>,<span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;
&gt;&gt; jFrameProxy.<span style="">handle</span>.<span style="">Minimized</span> = <span style="color: #0000FF;">true</span>;</pre></div></div><p>Using <code>FrameProxy</code> for figure minimization and maximization works correctly on both old and new Matlab releases; using <code>jFrame</code> is slightly simpler but only works on recent Matlab releases. Depending on your needs you may choose to use either of these. They are entirely equivalent.</p><p>When either the <b>Maximized</b> or <b>Minimized</b> properties are changed back to false, the window is restored to regular mode, which is the <code>FrameProxy</code>&#8216;s <b>RestoredLocation</b> and <b>RestoredSize</b>.</p><h3 id="JavaFrame">Use of the JavaFrame property</h3><p>Note that all this relies on the undocumented hidden figure property <b>JavaFrame</b>, which issues a standing warning (since Matlab release R2008a) of becoming obsolete in some future Matlab release (HG2?):</p><div
class="wp_syntax"><div
class="code"><pre style="font-family: monospace;"><span style="color: #000000;">>> jFrame = </span><span style="color: #0000ff;">get</span>(<span style="color: #0000ff;">gcf</span>,<span style="color: #800080;">'JavaFrame'</span>)
<span style="color: #ff0000;">Warning: figure JavaFrame property will be obsoleted in a future release.</span>
<span style="color: #000000;">For more information see the JavaFrame resource on the MathWorks web site.
(Type "warning off MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame" to suppress this warning.) 

jFrame =
com.mathworks.hg.peer.FigurePeer@1ffbad6</span>
</pre></div></div><p>To remove the above warning I have used (note the <i><b>handle</b></i> wrapper, as <a
target="_blank" href="http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comment-2756">suggested</a> by Donn Shull):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jFrame = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span></pre></div></div><p>If and when <b>JavaFrame</b> does become obsolete in some future Matlab version, be sure to look in this blog for workarounds.</p><p>You may also wish to inform MathWorks on the dedicated webpage that they have set up for specifically this reason (<a
target="_blank" rel="nofollow" href="http://www.mathworks.com/javaframe">http://www.mathworks.com/javaframe</a>), how you are using <b>JavaFrame</b> and why it is important for you. This may help them to decide whether to keep <b>JavaFrame</b> or possibly add the functionality using other means.</p><p>Do you have a smart use for the figure&#8217;s minimization or maximization feature? or another use for <b>JavaFrame</b>? If so, please share your ideas in a <a
target="_blank" href="http://UndocumentedMatlab.com/blog/minimize-maximize-figure-window#respond">comment</a> below.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/disable-entire-figure-window/' rel='bookmark' title='Enable/disable entire figure window'>Enable/disable entire figure window</a> <small>Disabling/enabling an entire figure window is impossible with pure Matlab, but is very simple using the underlying Java. This article explains how....</small></li><li><a
href='http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/' rel='bookmark' title='Transparent Matlab figure window'>Transparent Matlab figure window</a> <small>Matlab figure windows can be made fully or partially transparent/translucent or blurred - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/blurred-matlab-figure-window/' rel='bookmark' title='Blurred Matlab figure window'>Blurred Matlab figure window</a> <small>Matlab figure windows can be blurred using a semi-transparent overlaid window - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/detecting-window-focus-events/' rel='bookmark' title='Detecting window focus events'>Detecting window focus events</a> <small>Matlab does not have any documented method to detect window focus events (gain/loss). This article describes an undocumented way to detect such events....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/feed/</wfw:commentRss> <slash:comments>13</slash:comments> </item> <item><title>Blurred Matlab figure window</title><link>http://undocumentedmatlab.com/blog/blurred-matlab-figure-window/</link> <comments>http://undocumentedmatlab.com/blog/blurred-matlab-figure-window/#comments</comments> <pubDate>Wed, 20 Apr 2011 18:58:12 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Figure window]]></category> <category><![CDATA[GUI]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Listeners]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[JavaFrame]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2259</guid> <description><![CDATA[Matlab figure windows can be blurred using a semi-transparent overlaid window - this article explains how<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/' rel='bookmark' title='Transparent Matlab figure window'>Transparent Matlab figure window</a> <small>Matlab figure windows can be made fully or partially transparent/translucent or blurred - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/' rel='bookmark' title='Minimize/maximize figure window'>Minimize/maximize figure window</a> <small>Matlab figure windows can easily be maximized, minimized and restored using a bit of undocumented magic powder...</small></li><li><a
href='http://undocumentedmatlab.com/blog/disable-entire-figure-window/' rel='bookmark' title='Enable/disable entire figure window'>Enable/disable entire figure window</a> <small>Disabling/enabling an entire figure window is impossible with pure Matlab, but is very simple using the underlying Java. This article explains how....</small></li><li><a
href='http://undocumentedmatlab.com/blog/detecting-window-focus-events/' rel='bookmark' title='Detecting window focus events'>Detecting window focus events</a> <small>Matlab does not have any documented method to detect window focus events (gain/loss). This article describes an undocumented way to detect such events....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>Following my post two weeks ago about <a
target="_blank" href="http://undocumentedmatlab.com/blog/disable-entire-figure-window/">disabling an entire Matlab figure window</a>, and my article last week about <a
target="_blank" href="http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/">setting the transparency of a figure window</a>, I would like to combine these two functionalities into a blurred-window effect for a disabled window.</p><h3 id="basic">The basic idea</h3><p>The basic idea, as reader Mory <a
target="_blank" href="http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/#comment-40154">pointed out</a> in a comment, is to overlay a semi-transparent empty figure window, having just the right size and position, on top of the main (disabled) figure window:</p><p><center><div
class="wp-caption aligncenter" style="width: 640px"><img
alt="Main (unblurred) window" src="http://UndocumentedMatlab.com/images/blurFigure1a.png" title="Main (unblurred) window" width="190" /> + <img
alt="Semi-transparent window" src="http://UndocumentedMatlab.com/images/blurFigure1b.png" title="Semi-transparent window" width="190" /> = <img
alt="Blurred window effect" src="http://UndocumentedMatlab.com/images/blurFigure1c.png" title="Blurred window effect" width="190" /><p
class="wp-caption-text">Main (unblurred) window + semi-transparent window = blurred window effect</p></div></center></p><p>In addition to ensuring the correct figure size and position, there are several other things we should care for: We need to synchronize the figure/blurring color, menubar/toolbar, and title. We also need to handle docking, resizing and figure movement. Finally we need to connect the two figures so that whenever one is closed then so is the other.</p><h3 id="blurFigure">blurFigure</h3><p>My <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/30666-blurfigure-blurs-and-prevents-interaction-on-a-figure-window"><i><b>blurFigure</b></i> utility</a> on the Matlab File Exchange attempts to handle all these setups for the user. The utility is quite simple to use:</p><p><i><b>blurFigure</b>(hFig)</i> blurs figure <i>hFig</i> and prevents interaction with it. The only interaction possible is with user-created controls on the blurring panel (see below).</p><p>hFigBlur = <i><b>blurFigure</b>(hFig)</i> returns the overlaid blurred figure pane. This is useful to present a progress bar or other GUI controls, for user interaction during the blur phase (see the demo below).</p><p><i><b>blurFigure</b>(hFig,STATE)</i> sets the blur status of figure <i>hFig</i> to <i>STATE</i>, where state is &#8216;on&#8217;,'off&#8217;,true or false (default=&#8217;on&#8217;/true). <i><b>blurFigure</b>(hFig,&#8217;on&#8217;)</i> or <i><b>blurFigure</b>(hFig,true)</i> is the same as: <i><b>blurFigure</b>(hFig)</i>; <i><b>blurFigure</b>(hFig,&#8217;off&#8217;)</i> or <i><b>blurFigure</b>(hFig,false)</i> is the same as: <i><b>close</b>(hFigBlur)</i>.</p><p><i><b>blurFigure</b>(&#8216;demo&#8217;)</i> displays a simple demo of the blurring. In fact, this runs the following simple code:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Create the main (blurred) figure window</span>
hFigMain = <span style="color: #0000FF;">figure</span>;
&nbsp;
<span style="color: #228B22;">% Display some GUI controls in the main window</span>
<span style="color: #0000FF;">try</span> oldWarn = <span style="color: #0000FF;">warning</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'off'</span>,<span style="color:#A020F0;">'MATLAB:uitree:MigratingFunction'</span><span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">catch</span>, <span style="color: #0000FF;">end</span>
hTree = uitree<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'root'</span>,<span style="color:#A020F0;">'c:\'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">drawnow</span>;
<span style="color: #0000FF;">try</span> hTree.<span style="">getTree</span>.<span style="">expandRow</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">catch</span>, <span style="color: #0000FF;">end</span>
<span style="color: #0000FF;">try</span> <span style="color: #0000FF;">warning</span><span style="color: #080;">&#40;</span>oldWarn<span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">catch</span>, <span style="color: #0000FF;">end</span>
<span style="color: #0000FF;">uicontrol</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'string'</span>,<span style="color:#A020F0;">'click me!'</span>, <span style="color:#A020F0;">'units'</span>,<span style="color:#A020F0;">'pixel'</span>, <span style="color:#A020F0;">'pos'</span>,<span style="color: #080;">&#91;</span><span style="color: #33f;">300</span>,<span style="color: #33f;">50</span>,<span style="color: #33f;">100</span>,<span style="color: #33f;">20</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">axes</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'parent'</span>,<span style="color: #0000FF;">gcf</span>, <span style="color:#A020F0;">'units'</span>,<span style="color:#A020F0;">'pixel'</span>, <span style="color:#A020F0;">'pos'</span>,<span style="color: #080;">&#91;</span><span style="color: #33f;">230</span>,<span style="color: #33f;">100</span>,<span style="color: #33f;">300</span>,<span style="color: #33f;">300</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">surf</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">peaks</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span>,<span style="color:#A020F0;">'ToolBar'</span>,<span style="color:#A020F0;">'figure'</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% restore the toolbar that was removed by the uicontrol() call above</span>
&nbsp;
<span style="color: #228B22;">% Call blurFigure() to add a semi-transparent overlaid window</span>
hFigBlurTemp = blurFigure<span style="color: #080;">&#40;</span>hFigMain<span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Add some non-blurred controls on top of the blur</span>
<span style="color: #0000FF;">uicontrol</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'parent'</span>,hFigBlurTemp, <span style="color:#A020F0;">'style'</span>,<span style="color:#A020F0;">'text'</span>, <span style="color:#A020F0;">'units'</span>,<span style="color:#A020F0;">'pixel'</span>, <span style="color:#A020F0;">'pos'</span>,<span style="color: #080;">&#91;</span><span style="color: #33f;">130</span>,<span style="color: #33f;">85</span>,<span style="color: #33f;">390</span>,<span style="color: #33f;">80</span><span style="color: #080;">&#93;</span>, <span style="color: #F0F;">...</span>
          <span style="color:#A020F0;">'string'</span>,<span style="color:#A020F0;">'Processing - please wait...'</span>, <span style="color:#A020F0;">'FontSize'</span>,<span style="color: #33f;">12</span>, <span style="color:#A020F0;">'FontWeight'</span>,<span style="color:#A020F0;">'bold'</span>,<span style="color:#A020F0;">'Fore'</span>,<span style="color:#A020F0;">'red'</span>,<span style="color:#A020F0;">'Back'</span>,<span style="color:#A020F0;">'yellow'</span><span style="color: #080;">&#41;</span>;
jProgressBar = javacomponent<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'javax.swing.JProgressBar'</span>, <span style="color: #080;">&#91;</span><span style="color: #33f;">180</span>,<span style="color: #33f;">115</span>,<span style="color: #33f;">310</span>,<span style="color: #33f;">20</span><span style="color: #080;">&#93;</span>, hFigBlurTemp<span style="color: #080;">&#41;</span>;
jProgressBar.<span style="">setValue</span><span style="color: #080;">&#40;</span><span style="color: #33f;">67</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">uicontrol</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'parent'</span>,hFigBlurTemp, <span style="color:#A020F0;">'string'</span>,<span style="color:#A020F0;">'Cancel'</span>, <span style="color:#A020F0;">'pos'</span>,<span style="color: #080;">&#91;</span><span style="color: #33f;">280</span>,<span style="color: #33f;">90</span>,<span style="color: #33f;">100</span>,<span style="color: #33f;">20</span><span style="color: #080;">&#93;</span>, <span style="color:#A020F0;">'Callback'</span>,<span style="color:#A020F0;">'close(gcbf)'</span><span style="color: #080;">&#41;</span>;</pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 410px"><img
alt="Non-blurred controls displayed over a blurred figure window" src="http://UndocumentedMatlab.com/images/blurFigure.png" title="Non-blurred controls displayed over a blurred figure window" width="400" /><p
class="wp-caption-text">Non-blurred controls displayed over a blurred figure window</p></div></center></p><p>Do you have some other interesting uses for window transparency in Matlab? If so, please share your thought in a <a
href="http://undocumentedmatlab.com/blog/blurred-matlab-figure-window/#respond">comment</a>.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/' rel='bookmark' title='Transparent Matlab figure window'>Transparent Matlab figure window</a> <small>Matlab figure windows can be made fully or partially transparent/translucent or blurred - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/' rel='bookmark' title='Minimize/maximize figure window'>Minimize/maximize figure window</a> <small>Matlab figure windows can easily be maximized, minimized and restored using a bit of undocumented magic powder...</small></li><li><a
href='http://undocumentedmatlab.com/blog/disable-entire-figure-window/' rel='bookmark' title='Enable/disable entire figure window'>Enable/disable entire figure window</a> <small>Disabling/enabling an entire figure window is impossible with pure Matlab, but is very simple using the underlying Java. This article explains how....</small></li><li><a
href='http://undocumentedmatlab.com/blog/detecting-window-focus-events/' rel='bookmark' title='Detecting window focus events'>Detecting window focus events</a> <small>Matlab does not have any documented method to detect window focus events (gain/loss). This article describes an undocumented way to detect such events....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/blurred-matlab-figure-window/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Transparent Matlab figure window</title><link>http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/</link> <comments>http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/#comments</comments> <pubDate>Wed, 13 Apr 2011 23:22:38 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Figure window]]></category> <category><![CDATA[GUI]]></category> <category><![CDATA[Hidden property]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Desktop]]></category> <category><![CDATA[JavaFrame]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2246</guid> <description><![CDATA[Matlab figure windows can be made fully or partially transparent/translucent or blurred - this article explains how<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/blurred-matlab-figure-window/' rel='bookmark' title='Blurred Matlab figure window'>Blurred Matlab figure window</a> <small>Matlab figure windows can be blurred using a semi-transparent overlaid window - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/' rel='bookmark' title='Minimize/maximize figure window'>Minimize/maximize figure window</a> <small>Matlab figure windows can easily be maximized, minimized and restored using a bit of undocumented magic powder...</small></li><li><a
href='http://undocumentedmatlab.com/blog/disable-entire-figure-window/' rel='bookmark' title='Enable/disable entire figure window'>Enable/disable entire figure window</a> <small>Disabling/enabling an entire figure window is impossible with pure Matlab, but is very simple using the underlying Java. This article explains how....</small></li><li><a
href='http://undocumentedmatlab.com/blog/detecting-window-focus-events/' rel='bookmark' title='Detecting window focus events'>Detecting window focus events</a> <small>Matlab does not have any documented method to detect window focus events (gain/loss). This article describes an undocumented way to detect such events....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>Every now and then, a user asks whether it is possible to make an entire Matlab window transparent (<a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/newsreader/view_thread/280394">example</a>). This could be used, for example, for window fade-in/fade-out effects. The short answer is that there is no supported way of doing this with pure documented Matlab, but it is trivially easy to achieve using just a bit of Java magic powder (surprise, surprise).</p><h3 id="transparency">Matlab figure window transparency</h3><p>Following an idea I got from Malcolm Lidierth&#8217;s <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/28326-mutilities">MUtilities</a> submission on the Matlab File Exchange, the solution for setting Matlab figure window transparency is quite simple: Get the figure&#8217;s underlying Java window reference handle, as in <a
target="_blank" href="http://undocumentedmatlab.com/blog/disable-entire-figure-window/">last week&#8217;s</a> article. Then use Java&#8217;s <a
target="_blank" rel="nofollow" href="http://www.pushing-pixels.org/2008/02/27/translucent-and-shaped-windows-in-core-java.html"><i>setWindowOpacity</i> method</a> to set the window&#8217;s transparency value. Actually, <i>setWindowOpacity</i> sets the opacity level, rather than transparency, but they are obviously complementary and I personally find &#8220;transparency&#8221; to be more easily understandable.</p><p>By default, windows are created with an opacity of 1.0 (= not transparent). They can be set to any floating-point value between 0.0-1.0, where an opacity of 0.0 means full transparency, and any value in between means partial transparency (i.e., translucency):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jFigPeer = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span>;
jWindow = jFigPeer.<span style="">fFigureClient</span>.<span style="">getWindow</span>;
com.<span style="">sun</span>.<span style="">awt</span>.<span style="">AWTUtilities</span>.<span style="">setWindowOpacity</span><span style="color: #080;">&#40;</span>jWindow,<span style="color: #33f;">0.7</span><span style="color: #080;">&#41;</span></pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 510px"><a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fx_files/30583/1/setFigTransparency.png"><img
alt="Semi-transparent (translucent) Matlab figure (click to enlarge)" src="http://www.mathworks.com/matlabcentral/fx_files/30583/1/setFigTransparency.png" title="Semi-transparent (translucent) Matlab figure (click to enlarge)" width="500" /></a><p
class="wp-caption-text">Semi-transparent (translucent) Matlab figure (click to enlarge)</p></div></center></p><p>Similarly, you can set the entire Matlab Desktop&#8217;s transparency/opacity value:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jDesktop = com.<span style="">mathworks</span>.<span style="">mde</span>.<span style="">desk</span>.<span style="">MLDesktop</span>.<span style="">getInstance</span>.<span style="">getMainFrame</span>;
com.<span style="">sun</span>.<span style="">awt</span>.<span style="">AWTUtilities</span>.<span style="">setWindowOpacity</span><span style="color: #080;">&#40;</span>jDesktop, <span style="color: #33f;">0.8</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Note that the <code>com.sun.awt.AWTUtilities</code> class also enables <a
target="_blank" rel="nofollow" href="http://today.java.net/pub/a/today/2008/03/18/translucent-and-shaped-swing-windows.html">other GUI effects</a> that would make a Matlab GUI developer&#8217;s mouth to start drooling: shaped windows, per-pixel transparency values, mirroring/reflection, window shadows, <a
target="_blank" rel="nofollow" href="http://java.sun.com/developer/technicalArticles/GUI/translucent_shaped_windows/">gradients</a> etc. Perhaps I&#8217;ll explore their adaptation for Matlab figures someday.</p><h3 id="Fade">Fade-in / fade-out</h3><p>Window fade-in/fade-out effects can easily be achieved using transparency: Simply invoke the <i>setWindowOpacity</i> method several times, with progressively higher or lower values. This is easily done in a simple blocking loop. For example, to fade-out a window:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">for</span> stepIdx = <span style="color: #33f;">1</span> <span style="color: #F0F;">:</span> <span style="color: #33f;">5</span>
   newAlpha = <span style="color: #33f;">1.0</span> - <span style="color: #33f;">0.2</span>*stepIdx;
   com.<span style="">sun</span>.<span style="">awt</span>.<span style="">AWTUtilities</span>.<span style="">setWindowOpacity</span><span style="color: #080;">&#40;</span>jWindow,newAlpha<span style="color: #080;">&#41;</span>;
   jWindow.<span style="">repaint</span>;
   <span style="color: #0000FF;">pause</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0.2</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% seconds</span>
<span style="color: #0000FF;">end</span></pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 310px"><img
alt="Gradual window fade-out" src="http://UndocumentedMatlab.com/images/transparent_figure_animated.gif" title="Gradual window fade-out" width="300" /><p
class="wp-caption-text">Gradual window fade-out</p></div></center></p><p>A more general example dynamically computes the opacity step size/duration and also enables non-blocking fade effects using an asynchronous timer:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Compute the required opacity-setting steps</span>
fadeDuration = <span style="color: #33f;">1.5</span>;  <span style="color: #228B22;">% seconds</span>
oldAlpha = com.<span style="">sun</span>.<span style="">awt</span>.<span style="">AWTUtilities</span>.<span style="">getWindowOpacity</span><span style="color: #080;">&#40;</span>jWindow<span style="color: #080;">&#41;</span>;
newAlpha = <span style="color: #33f;">0.0</span>;
deltaAlpha = newAlpha - oldAlpha;
maxStepAlpha = <span style="color: #33f;">0.03</span>;
steps = <span style="color: #0000FF;">fix</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">abs</span><span style="color: #080;">&#40;</span>deltaAlpha<span style="color: #080;">&#41;</span> / maxStepAlpha<span style="color: #080;">&#41;</span> + <span style="color: #33f;">1</span>;
stepAlpha = deltaAlpha / steps;
stepDuration = fadeDuration / <span style="color: #080;">&#40;</span>steps-<span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% If blocking, do the fade effect immediately</span>
<span style="color: #0000FF;">if</span> blockingFlag <span style="color: #F0F;">||</span> steps==<span style="color: #33f;">1</span>
   <span style="color: #0000FF;">for</span> stepIdx = <span style="color: #33f;">1</span> <span style="color: #F0F;">:</span> steps
      newAlpha = oldAlpha + stepAlpha*stepIdx;
      com.<span style="">sun</span>.<span style="">awt</span>.<span style="">AWTUtilities</span>.<span style="">setWindowOpacity</span><span style="color: #080;">&#40;</span>jWindow,newAlpha<span style="color: #080;">&#41;</span>;
      jWindow.<span style="">repaint</span>;
      <span style="color: #0000FF;">if</span> stepIdx &lt; steps,  <span style="color: #0000FF;">pause</span><span style="color: #080;">&#40;</span>stepDuration<span style="color: #080;">&#41;</span>;  <span style="color: #0000FF;">end</span>
   <span style="color: #0000FF;">end</span>
<span style="color: #0000FF;">else</span>
   <span style="color: #228B22;">% non-blocking: fade in/out asynchronously using a dedicated timer</span>
   start<span style="color: #080;">&#40;</span>timer<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'ExecutionMode'</span>,<span style="color:#A020F0;">'fixedRate'</span>, <span style="color:#A020F0;">'Period'</span>,<span style="color: #33f;">0.1</span>, <span style="color:#A020F0;">'TasksToExecute'</span>,steps, <span style="color: #F0F;">...</span>
               <span style="color:#A020F0;">'TimerFcn'</span>, <span style="color: #080;">&#123;</span>@timerFcn,jWindow,oldAlpha,stepAlpha<span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">end</span>
&nbsp;
<span style="color: #228B22;">% Timer function for non-blocking fade-in/fade-out effect</span>
<span style="color: #0000FF;">function</span> timerFcn<span style="color: #080;">&#40;</span>hTimer,eventData,jFrame,currentAlpha,stepAlpha<span style="color: #080;">&#41;</span>  <span style="color: #228B22;">%#ok&lt;INUSL&gt; eventData</span>
  stepIdx = hTimer.<span style="">TasksExecuted</span>;
  newAlpha = currentAlpha + stepAlpha*stepIdx;
  com.<span style="">sun</span>.<span style="">awt</span>.<span style="">AWTUtilities</span>.<span style="">setWindowOpacity</span><span style="color: #080;">&#40;</span>jFrame,newAlpha<span style="color: #080;">&#41;</span>;
  jFrame.<span style="">repaint</span>;
  <span style="color: #0000FF;">if</span> stepIdx == hTimer.<span style="">TasksToExecute</span>
      stop<span style="color: #080;">&#40;</span>hTimer<span style="color: #080;">&#41;</span>;
      <span style="color: #0000FF;">delete</span><span style="color: #080;">&#40;</span>hTimer<span style="color: #080;">&#41;</span>;
  <span style="color: #0000FF;">end</span>
<span style="color: #0000FF;">end</span>  <span style="color: #228B22;">% timerFcn</span></pre></div></div><p>Of course, you can also fade-in/out to intermediate values such as 0.3 or 0.8. If you fade-out completely (i.e., to a value of 0.0), it might be a good idea to actually <i><b>close</b></i> the figure window once it gets the totally-transparent value of 0.0.</p><p>I&#8217;ve prepared a Matlab utility that contains all these options, including optional blocking/non-blocking fade effects, in my <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/30583-setfigtransparency-set-figure-transparency-fading"><i><b>setFigTransparency</b></i> utility</a>, which is available for download on the Matlab File Exchange. You may also wish to use Malcolm Lidierth&#8217;s <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/28326-mutilities">MUtilities</a>, which also has similar functionalities (plus some other goodies).</p><h3 id="Limitations">Limitations</h3><p>Setting a figure window&#8217;s transparency requires using Java Run-time Engine (JRE) 1.6.0_10 (also called &#8220;Java 6 update 10&#8243;) or higher. This means that it&#8217;s supported on Matlab release 7.9 (R2009b) and higher by default, and on earlier releases using a JRE retrofit.</p><p>If you are using an earlier Matlab release, consider a retrofit of JRE 1.6.0_10 or any later version (e.g., the latest available version today is 1.6 update 24). The JRE can be downloaded from <a
target="_blank" rel="nofollow" href="http://java.com/en/download/manual.jsp">here</a>, and you can configure Matlab to use it according to the instructions <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/support/solutions/en/data/1-1812J/">here</a>. As noted, Matlab R2009b (7.9) and onward, at least on Microsoft Windows, pre-bundle a JRE version that does support transparency/opacity and so do not require a retrofit.</p><p>You can check your current Java version in Matlab as follows:</p><div
class="wp_syntax"><div
class="code"><pre class="text" style="font-family:monospace;">&gt;&gt; version -java
ans =
Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode</pre></div></div><p>Unfortunately, Matlab plot axes cannot be made transparent. If you have any axes in your GUI, the axes area will simply appear as a shaded axes, whose intensity depends on the selected alpha (transparency) value; the contents beneath the window will not be merged in the axes area as it is in the non-axes areas.</p><p>Finally, note that <code>com.sun.awt.AWTUtilities</code> is itself an undocumented Java class. It is bundled with the standard Java release since 2008 (1.6.0_10), and yet is not part of the official release because its API has not yet settled. In fact, in the upcoming Java 7 release, which is expected in a few months, and which I expect to be available in Matlab sometime in 2012, the set of transparency/opacity methods have <a
target="_blank" rel="nofollow" href="http://www.pushing-pixels.org/2009/05/03/translucent-and-shaped-windows-in-jdk-7.html">migrated</a> to the fully-documented <code>java.awt.Window</code> class.</p><h3 id="blurring">Blurred figure window</h3><p>So here&#8217;s a riddle for you: using figure window transparency, can you guess how to make a Matlab figure appear blurred for <a
target="_blank" href="http://undocumentedmatlab.com/blog/disable-entire-figure-window/">disabled figures</a> (see the screenshot there)? There are several possible ways to do this &#8211; can you find the simplest? The first one to <a
target="_blank" href="http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/#respond">post a comment</a> with a correct answer gets a smiley&#8230; My answer will appear in next week&#8217;s article.</p><h3 id="upgrade">Upgraded website</h3><p>Also, did you notice my new website design? It&#8217;s supposed to be much more readable (yes &#8211; also on <a
target="_blank" rel="nofollow" href="http://blogs.mathworks.com/desktop/2010/05/24/introducing-matlab-mobile-%E2%80%93-an-iphone-app-to-connect-remotely-to-your-matlab/#comments">Android</a>&#8230;). It now also runs on a multi-server cloud, which means more stability and faster response times. Do you like the new design? hate it? I would love to hear your feedback via <a
target="_blank" href="http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/#respond">comment</a> or <a
href="mailto:%20altmany%20@gmail.com?subject=Undocumented%20Matlab&amp;body=Hi%20Yair,%20&amp;cc=;&amp;bcc=" rel="nofollow" target="_blank" onclick="var n='altmany'; var d='gmail.com'; window.open('mailto:'+n+'@'+d+'?subject=Undocumented Matlab&amp;body=Hi Yair, '); return false;">email</a>.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/blurred-matlab-figure-window/' rel='bookmark' title='Blurred Matlab figure window'>Blurred Matlab figure window</a> <small>Matlab figure windows can be blurred using a semi-transparent overlaid window - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/' rel='bookmark' title='Minimize/maximize figure window'>Minimize/maximize figure window</a> <small>Matlab figure windows can easily be maximized, minimized and restored using a bit of undocumented magic powder...</small></li><li><a
href='http://undocumentedmatlab.com/blog/disable-entire-figure-window/' rel='bookmark' title='Enable/disable entire figure window'>Enable/disable entire figure window</a> <small>Disabling/enabling an entire figure window is impossible with pure Matlab, but is very simple using the underlying Java. This article explains how....</small></li><li><a
href='http://undocumentedmatlab.com/blog/detecting-window-focus-events/' rel='bookmark' title='Detecting window focus events'>Detecting window focus events</a> <small>Matlab does not have any documented method to detect window focus events (gain/loss). This article describes an undocumented way to detect such events....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>Enable/disable entire figure window</title><link>http://undocumentedmatlab.com/blog/disable-entire-figure-window/</link> <comments>http://undocumentedmatlab.com/blog/disable-entire-figure-window/#comments</comments> <pubDate>Wed, 06 Apr 2011 18:00:20 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Figure window]]></category> <category><![CDATA[GUI]]></category> <category><![CDATA[Hidden property]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Internal component]]></category> <category><![CDATA[JavaFrame]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2089</guid> <description><![CDATA[Disabling/enabling an entire figure window is impossible with pure Matlab, but is very simple using the underlying Java. This article explains how.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/' rel='bookmark' title='Minimize/maximize figure window'>Minimize/maximize figure window</a> <small>Matlab figure windows can easily be maximized, minimized and restored using a bit of undocumented magic powder...</small></li><li><a
href='http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/' rel='bookmark' title='Transparent Matlab figure window'>Transparent Matlab figure window</a> <small>Matlab figure windows can be made fully or partially transparent/translucent or blurred - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/blurred-matlab-figure-window/' rel='bookmark' title='Blurred Matlab figure window'>Blurred Matlab figure window</a> <small>Matlab figure windows can be blurred using a semi-transparent overlaid window - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/detecting-window-focus-events/' rel='bookmark' title='Detecting window focus events'>Detecting window focus events</a> <small>Matlab does not have any documented method to detect window focus events (gain/loss). This article describes an undocumented way to detect such events....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>Some time ago, a reader on the CSSM newsgroup <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/newsreader/view_thread/300200">asked</a> whether it is possible to disable an entire figure window while some processing is taking place. Last week, Mike posted an article about the built-in functions <b><i>uiwait</i></b> and <b><i>uiresume</i></b> on <a
rel="nofollow" target="_blank" href="http://blogs.mathworks.com/desktop/2011/03/28/using-uiwaituiresume-to-control-program-flow/">MathWork&#8217;s Matlab Desktop blog</a>, which more-or-less answers this need. Today I will expand the answer based on several undocumented/unsupported mechanisms.</p><h3 id="uiwait">Uiwait and uiresume</h3><p>We start with a short review of the supported mechanism: We can use the built-in <b><i>uiwait</i></b> function to suspend Matlab processing until either the specified handle (typically a figure handle) is deleted/closed, a user callback programmatically calls <b><i>uiresume</i></b>, or Ctrl-C is pressed. A short example, adapted from <b><i>uiwait</i></b>&#8216;s help section (the official help section has a bug, so if anyone reads this at TMW, please fix):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">h = <span style="color: #0000FF;">uicontrol</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Position'</span>, <span style="color: #080;">&#91;</span><span style="color: #33f;">20</span> <span style="color: #33f;">20</span> <span style="color: #33f;">200</span> <span style="color: #33f;">40</span><span style="color: #080;">&#93;</span>, <span style="color:#A020F0;">'String'</span>, <span style="color:#A020F0;">'Continue'</span>, <span style="color:#A020F0;">'Callback'</span>, <span style="color:#A020F0;">'uiresume(gcbf)'</span><span style="color: #080;">&#41;</span>;
f = <span style="color: #0000FF;">gcf</span>;
<span style="color: #0000FF;">disp</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'This will print immediately'</span><span style="color: #080;">&#41;</span>;
uiwait<span style="color: #080;">&#40;</span>f<span style="color: #080;">&#41;</span>; 
<span style="color: #0000FF;">disp</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'This will print after you click Continue or close the window'</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Close the figure (use try-catch in case f is already closed)</span>
<span style="color: #0000FF;">try</span> <span style="color: #0000FF;">close</span><span style="color: #080;">&#40;</span>f<span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">catch</span>, <span style="color: #0000FF;">end</span></pre></div></div><p>Unfortunately, the side effect is that <b><i>uiwait</i></b> blocks the regular (non-callback&#8217;ed) processing until the lock is released. This is great for simple cases where we require a user to respond to a popup window (e.g., message-box or input dialog) before being allowed to proceed. In more complex situations we may wish to suspend interaction on certain figure windows while continuing to process Matlab functionality &#8211; this is impossible to do using <b><i>uiwait</i></b>.</p><p>Matlab does not have any documented way to disable an entire figure window. You can set the figure&#8217;s <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/help/techdoc/ref/figure_props.html#WindowStyle"><b>WindowStyle</b> property</a> to &#8216;modal&#8217; but this is not the same: (1) it removes the toolbar and menu-bar (2) it still enables interaction with all the figure&#8217;s GUI controls and (3) it prevents access to any other Matlab window or desktop until the modal figure is closed. This is certainly NOT what we need.</p><p>Of course, we could always loop over all the relevant GUI handles and set their <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/help/techdoc/ref/uicontrol_props.html#Enable"><b>Enable</b> property</a> to &#8216;inactive&#8217; or &#8216;off&#8217;. But this is tedious, lengthy, and in complex GUIs that have multiple layers of nested panels, it also requires careful recursive programming. We also need to take care to disable hidden handles, toolbars, menu-bars, context-menus, Java components &#8211; all these have different ways of being accessed and disabled. And once we <b><i>uiresume</i></b> from the lock, we need to remember each handle&#8217;s pre-<b><i>uiwait</i></b> state, so that if it was disabled before the call to <b><i>uiwait</i></b>, it will remain so after <b><i>uiresume</i></b>. In short, this is not a trivial exercise at all.</p><h3 id="uisuspend">Uisuspend and uirestore</h3><p>To complicate things, the fully-documented and supported <b><i>uiwait</i></b> and <b><i>uiresume</i></b> functions have the <a
target="_blank" href="http://undocumentedmatlab.com/blog/legend-semi-documented-feature/#Semi-documented">semi-documented</a> unsupported built-in counterparts <b><i>uisuspend</i></b> and <b><i>uirestore</i></b>, which are very similar in functionality and name. It is important not to confuse between these two function sets, and most importantly, not to confuse between <b><i>uiresume</i></b> and <b><i>uirestore</i></b> after using their counterparts earlier in the code – odd things might happen if you do&#8230;</p><p>Hopefully, in a nearby Matlab release these inconsistencies between the two function sets will disappear and they will be merged, because the current situation is prone to errors and confusion. For backward compatibility considerations, I hope that <b><i>uisuspend</i></b> and <b><i>uirestore</i></b> would not be discontinued but rather be modified to simply call <b><i>uiwait</i></b> and <b><i>uiresume</i></b>.</p><p>Note that in Matlab releases up to R2010b, <b><i>uirestore</i></b> had a <a
rel="nofollow" target="_blank" href="http://www.mathworks.com/support/bugreports/646025 ">minor bug</a> in that it overwrites the figure&#8217;s <b>WindowScrollWheelFcn</b> callback with the <b>WindowKeyPressFcn</b> value. This bug was finally fixed in R2011a.</p><h3 id="Method">How to enable/disable a figure window</h3><p>So going back to the main question, we want to find a way to disable an entire figure window, in one simple stroke, and without blocking the Matlab processing.</p><p>As usual, we turn to Java and the solution is trivially simple:</p><p>First, get the figure window&#8217;s underlying Java reference. Note that we need the top-level container reference, rather than the proxy peer handle returned by the <b>JavaFrame</b> hidden property:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; jFigPeer = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span>
jFigPeer =
com.<span style="">mathworks</span>.<span style="">hg</span>.<span style="">peer</span>.<span style="">FigurePeer</span>@1ffbad6
&nbsp;
&gt;&gt; jWindow = jFigPeer.<span style="">fFigureClient</span>.<span style="">getWindow</span>
<span style="color: #0000FF;">ans</span> =
com.<span style="">mathworks</span>.<span style="">hg</span>.<span style="">peer</span>.<span style="">FigureFrameProxy</span>$FigureFrame<span style="color: #080;">&#91;</span><span style="color: #F0F;">...</span><span style="color: #080;">&#93;</span></pre></div></div><p>Now remember that all Java GUI components (on which Matlab GUI is based) contain an <a
target="_blank" rel="nofollow" href="http://download.oracle.com/javase/6/docs/api/java/awt/Component.html#setEnabled%28boolean%29"><b>Enabled</b> property</a>. So, simply set this property on the jWindow reference to true or false:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jWindow.<span style="">setEnabled</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% or true</span>
&nbsp;
<span style="color: #228B22;">% an equivalent alternative</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span>jWindow<span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'Enabled'</span>,<span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>  <span style="color: #228B22;">% or true</span></pre></div></div><p>By the way, if you only need to disable the figure&#8217;s content area (i.e., not the toolbar and menu bar), simply use a different reference handle:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jFigPeer.<span style="">getFigurePanelContainer</span>.<span style="">setEnabled</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% or true</span></pre></div></div><p>Notes:</p><ul><li>While the window looks the same when it is disabled, in reality none of its GUI elements can be clicked or activated (try it!). If you also want the figure to appear blurred you could try using something like a <a
target="_blank" rel="nofollow" href="http://java.net/projects/jxlayer/">JXLayer</a> semi-translucent glass pane.</li><li>The Java components&#8217; property is called <b>Enabled</b>, not <b>Enable</b> as in pure-Matlab Handle-Graphics controls. Also, the Java property expects true/false (or 0/1), rather than Matlab&#8217;s &#8216;on&#8217;/'off&#8217; (there are some fine details here that are release-specific so I will skip them)</li><li>For docked windows the top-level window is the figure&#8217;s group container window or the desktop window, which we do not want to disable. Detecting this is easy (check whether the figure&#8217;s <b>WindowStyle</b> is &#8216;docked&#8217;), and in such cases simply disable/enable the figure&#8217;s content area as shown above.</li></ul><h3 id="JavaFrame">Use of the JavaFrame property</h3><p>Note that all this relies on the undocumented hidden figure property <b>JavaFrame</b>, which issues a standing warning (since Matlab release R2008a) of becoming obsolete in some future Matlab release (HG2?):</p><div
class="wp_syntax"><div
class="code"><pre style="font-family: monospace;"><span style="color: #000000;">>> jFigPeer = </span><span style="color: #0000ff;">get</span>(<span style="color: #0000ff;">gcf</span>,<span style="color: #800080;">'JavaFrame'</span>)
<span style="color: #ff0000;">Warning: figure JavaFrame property will be obsoleted in a future release.</span>
<span style="color: #000000;">For more information see the JavaFrame resource on the MathWorks web site.
(Type "warning off MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame"
to suppress this warning.) 

jFigPeer =
com.mathworks.hg.peer.FigurePeer@1ffbad6</span>
</div>
</div>
</pre><p>To remove the above warning I have used (note the <i><b>handle</b></i> wrapper, as <a
target="_blank" href="http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comment-2756">suggested</a> by Donn Shull):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jFigPeer = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span></pre></div></div><p>If and when <b>JavaFrame</b> does become obsolete in some future Matlab version, be sure to look in this blog for workarounds.</p><p>You may also wish to inform MathWorks on the dedicated webpage that they have set up for specifically this reason (<a
target="_blank" rel="nofollow" href="http://www.mathworks.com/javaframe">http://www.mathworks.com/javaframe</a>), how you are using <b>JavaFrame</b> and why it is important for you. This may help them to decide whether to keep <b>JavaFrame</b> or possibly add the functionality using other means.</p><h3 id="enableDisableFig">The enableDisableFig utility</h3><p>In 2007, I created the <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/15895-enabledisable-figure"><i><b>enableDisableFig</b></i> utility</a> that wraps the above code in an easy-to-use Matlab utility that I have uploaded to the File Exchange.</p><p><i><b>enableDisableFig</b></i> returns the current state of the specified figure handle (or <i><b>gcf</b></i> if no handle is specified), and optionally sets the figure&#8217;s enabled/disabled state to a new value (&#8216;on&#8217;,'off&#8217;, true or false):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; oldState = enableDisableFig<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span>, <span style="color:#A020F0;">'on'</span><span style="color: #080;">&#41;</span>
oldState =
on
&nbsp;
&gt;&gt; enableDisableFig<span style="color: #080;">&#40;</span>oldState<span style="color: #080;">&#41;</span>;
&gt;&gt; enableDisableFig<span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% an alternative</span></pre></div></div><p><i><b>enableDisableFig</b></i> also provides some sanity checks and error handling that should always appear in any real-world application. In this blog I generally tend to provide only bare-bones code snippets (as above). But in any respected application we must check the validity of input arguments and return values, catch run-time errors, compensate for incompatibilities with older Matlab release and so on. Take a look at <i><b>enableDisableFig</b></i>&#8216;s source code to see how I have done this.</p><h3 id="visual">Visual aid</h3><p>When any GUI control is disabled, the accepted convention is to shade it in a gray color as a visual aid to the user that the control is currently disabled. This is automatically done by Matlab when any control&#8217;s <b>Enable</b> property is set to &#8216;off&#8217;. In our case, it would be very helpful to display a similar blurring effect for the disabled figure window.</p><p>Would you be very surprised if I told you that this is impossible to do with regular Matlab, but trivially easy to achieve using a tiny bit of Java magic powder? I&#8217;ll expand on this in my next post, but here&#8217;s something to keep you waiting:</p><p><center><div
class="wp-caption aligncenter" style="width: 460px"><img
alt="A blurred disabled figure" src="http://UndocumentedMatlab.com/images/blurFigure.png" title="A blurred disabled figure" width="450" /><p
class="wp-caption-text">A blurred disabled figure</p></div></center></p><h3 id="upgrade">Server upgrade</h3><p>This weekend (9-10 April, 2011) I plan to upgrade the website. This will entail moving to a different webserver, database, upgraded blogging application, new design etc. This site may be down or &#8220;goofy&#8221; for quite a few hours. Hopefully all will be back to normal by Monday and I hope you will like the new design.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/' rel='bookmark' title='Minimize/maximize figure window'>Minimize/maximize figure window</a> <small>Matlab figure windows can easily be maximized, minimized and restored using a bit of undocumented magic powder...</small></li><li><a
href='http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/' rel='bookmark' title='Transparent Matlab figure window'>Transparent Matlab figure window</a> <small>Matlab figure windows can be made fully or partially transparent/translucent or blurred - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/blurred-matlab-figure-window/' rel='bookmark' title='Blurred Matlab figure window'>Blurred Matlab figure window</a> <small>Matlab figure windows can be blurred using a semi-transparent overlaid window - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/detecting-window-focus-events/' rel='bookmark' title='Detecting window focus events'>Detecting window focus events</a> <small>Matlab does not have any documented method to detect window focus events (gain/loss). This article describes an undocumented way to detect such events....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/disable-entire-figure-window/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>FindJObj &#8211; find a Matlab component&#8217;s underlying Java object</title><link>http://undocumentedmatlab.com/blog/findjobj-find-underlying-java-object/</link> <comments>http://undocumentedmatlab.com/blog/findjobj-find-underlying-java-object/#comments</comments> <pubDate>Wed, 06 Jan 2010 21:06:33 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Figure window]]></category> <category><![CDATA[GUI]]></category> <category><![CDATA[Handle graphics]]></category> <category><![CDATA[High risk of breaking in future versions]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[UI controls]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[FindJObj]]></category> <category><![CDATA[JavaFrame]]></category> <category><![CDATA[PixelBounds]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=892</guid> <description><![CDATA[The FindJObj utility can be used to access and display the internal components of Matlab controls and containers. This article explains its uses and inner mechanism.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/findjobj-gui-display-container-hierarchy/' rel='bookmark' title='FindJObj GUI &#8211; display container hierarchy'>FindJObj GUI &#8211; display container hierarchy</a> <small>The FindJObj utility can be used to present a GUI that displays a Matlab container's internal Java components, properties and callbacks....</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-status-bar-components/' rel='bookmark' title='Setting status-bar components'>Setting status-bar components</a> <small>Matlab status-bars are Java containers in which we can add GUI controls such as progress-bars, not just simple text labels...</small></li><li><a
href='http://undocumentedmatlab.com/blog/date-selection-components/' rel='bookmark' title='Date selection components'>Date selection components</a> <small>The JIDE package, pre-bundled in Matlab, contains several GUI controls for selecting dates - this article explains how they can be used...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-type-selection-components/' rel='bookmark' title='Plot-type selection components'>Plot-type selection components</a> <small>Several built-in components enable programmatic plot-type selection in Matlab GUI - this article explains how...</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>In a previous post, I explained that all Matlab GUI (except the axes plotting engine) is based on Java components, and showed how we can use this information to <a
target="_blank" href="http://undocumentedmatlab.com/blog/html-support-in-matlab-uicomponents/">display HTML contents in Matlab <b><i>uicontrol</i></b>s</a>. In <a
target="_blank" href="http://undocumentedmatlab.com/blog/tag/findjobj/">other posts</a>, I have shown how a utility called <b><i>findjobj</i></b> can be used to access the underlying Java components to enable customizations that are unavailable in standard Matlab: <a
target="_blank" href="http://undocumentedmatlab.com/blog/setting-line-position-in-edit-box-uicontrol/">setting the line location in an edit-box</a>, <a
target="_blank" href="http://undocumentedmatlab.com/blog/button-customization/">customizing button appearance</a>, <a
target="_blank" href="http://undocumentedmatlab.com/blog/uicontrol-callbacks/">setting uicontrol callbacks</a>, or <a
target="_blank" href="http://undocumentedmatlab.com/blog/setting-listbox-mouse-actions/">setting list-box mouse actions</a>. I have also shown how <b><i>findjobj</i></b> can be used to display the component hierarchy of complex Matlab containers such as the <a
target="_blank" href="http://undocumentedmatlab.com/blog/figure-toolbar-customizations/">figure window</a>, <a
target="_blank" href="http://undocumentedmatlab.com/blog/guide-customization/">GUIDE</a> or the <a
target="_blank" href="http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/">Editor</a>.</p><p>The time is therefore well overdue for a formal introduction of <b><i>findjobj</i></b>, explaining its uses and internal mechanism. Of course, readers are welcome to continue using <b><i>findjobj</i></b> as a black-box utility, but I think important insight can be gained from understanding its inner details. <b><i>Findjobj</i></b>&#8216;s code is available for free download on the <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/14317">MathWorks File Exchange</a>. It is one of my favorite submissions and is apparently well-liked by users, being highly reviewed and highly downloaded.</p><p><b><i>Findjobj</i></b> has two main purposes:</p><ol><li>Find the underlying Java object reference of a given Matlab handle &#8211; Historically this was the original purpose, hence the utility&#8217;s name. <b><i>Findjobj</i></b> was meant to extend Matlab&#8217;s standard <b><i>findobj</i></b> function, which does not expose Java components.</li><li>Display a container&#8217;s internal components hierarchy in a graphical user interface, to facilitate visualization of complex containers. This was later extended to also display and allow modification of the sub-components&#8217; properties and callbacks.</li></ol><p>Today I will focus on the first (programmatic) aspect;  next week I will describe the second (GUI) aspect.</p><p><b><i>Findjobj</i></b>&#8216;s heart is finding a control&#8217;s underlying Java handle. Unfortunately, this is not exposed by Matlab except in very rare cases. As hard as I tried, I could not find a way to directly access the underlying Java-peer handle. I therefore resorted to getting the control&#8217;s enclosing Java frame (window) reference, and then working down its sub-components hierarchy until finding the Java object(s) which satisfy the position and/or class criteria. To get the enclosing Java frame (aka <i>TopLevelAncestor</i>), I use the Matlab figure&#8217;s undocumented <b>JavaFrame</b> property. Using this property issues a standard warning (since Matlab release R2008a) of becoming obsolete in some future Matlab release. Since it worked so far, I have turned off this warning in <b><i>findjobj</i></b>&#8216;s code, but note that this code may well fail in some future Matlab version. If and when <b>JavaFrame</b> does become obsolete, be sure to look in this blog for workarounds…</p><p>Traversing the frame&#8217;s hierarchy presents several challenges: Main-menu items are accessed using different functions than other Swing components or sub-containers, and are not automatically accessible until first displayed. I have overcome this latter challenge by simulating a menu-open action in case menus should be searched (this is off by default since it takes several seconds and also changes the GUI focus). For &#8220;regular&#8221; sub-containers, sometimes we need to loop over <i>getComponent(&#8230;)</i> and in some other cases over <i>getChildAt(&#8230;)</i>.</p><p>Another challenge was presented by the fact that Java positions start at (0,0) in the <u>top</u> left corner increasing rightward and <u>downward</u>, rather than starting at (1,1) in the bottom left and increasing upward as in Matlab. Moreover, Java positions are always pixel-based and relative to their parent container, which is different from Matlab (if the Matlab units is &#8216;pixels&#8217; then the value is absolute; if &#8216;normalized&#8217; then it returns a non-pixel value). To further complicate matters, some Matlab controls have a different size than their Java counterparts: some controls have a 5-pixel margins while others not, some controls are shifted by a pixel or two from their container&#8217;s border (for a total offset of up to 7 pixels), while some controls (such as popup-menus) have an entirely different reported size. In theory, we could use the Matlab component&#8217;s undocumented <b>PixelBounds</b> property (much faster than <b><i>getpixelposition</i></b>), but unfortunately <b>PixelBounds</b> turns out to be unreliable and returns erroneous values in many cases. Finally, different Java containers/components have different ways of returning their position: for some it is a <i>getLocation()</i> method, for others it is <i>getX()/getY()</i> and for others it is the <b>X</b> and <b>Y</b> properties (that sometimes have no corresponding <i>getX()/getY()</i> accessor methods!).</p><p>Having finally overcome all these challenges (and quite a few smaller ones, documented within the source code), I have wrapped the algorithm in a function interface that tries to emulate <b><i>findobj</i></b>&#8216;s. Using <b><i>findjobj</i></b> can now be as easy as:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Modify the mouse cursor when over the button</span>
hButton = <span style="color: #0000FF;">uicontrol</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'string'</span>,<span style="color:#A020F0;">'click me!'</span><span style="color: #080;">&#41;</span>;
jButton = findjobj<span style="color: #080;">&#40;</span>hButton<span style="color: #080;">&#41;</span>;
jButton.<span style="">setCursor</span><span style="color: #080;">&#40;</span>java.<span style="">awt</span>.<span style="">Cursor</span><span style="color: #080;">&#40;</span>java.<span style="">awt</span>.<span style="">Cursor</span>.<span style="">HAND_CURSOR</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span></pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 260px"><img
alt="Modified uicontrol cursor - a Java property" src="http://UndocumentedMatlab.com/images/button_cursor_hand.png" title="Modified uicontrol cursor - a Java property" width="105" height="66" /><p
class="wp-caption-text">Modified uicontrol cursor - a Java property</p></div></center></p><p>&#8230;or as complex as:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Find all non-button controls with the specified label</span>
jControls = findjobj<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'property'</span>,<span style="color: #080;">&#123;</span><span style="color:#A020F0;">'text'</span>,<span style="color:#A020F0;">'click me!'</span><span style="color: #080;">&#125;</span>, <span style="color:#A020F0;">'not'</span>,<span style="color:#A020F0;">'class'</span>,<span style="color:#A020F0;">'button'</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Space here is limited and <b><i>findjobj</i></b> is over 2500 lines long, so I have obviously not covered everything. I encourage you to <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/14317">download the utility</a> and explore the code, and I gladly welcome your feedback.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/findjobj-gui-display-container-hierarchy/' rel='bookmark' title='FindJObj GUI &#8211; display container hierarchy'>FindJObj GUI &#8211; display container hierarchy</a> <small>The FindJObj utility can be used to present a GUI that displays a Matlab container's internal Java components, properties and callbacks....</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-status-bar-components/' rel='bookmark' title='Setting status-bar components'>Setting status-bar components</a> <small>Matlab status-bars are Java containers in which we can add GUI controls such as progress-bars, not just simple text labels...</small></li><li><a
href='http://undocumentedmatlab.com/blog/date-selection-components/' rel='bookmark' title='Date selection components'>Date selection components</a> <small>The JIDE package, pre-bundled in Matlab, contains several GUI controls for selecting dates - this article explains how they can be used...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-type-selection-components/' rel='bookmark' title='Plot-type selection components'>Plot-type selection components</a> <small>Several built-in components enable programmatic plot-type selection in Matlab GUI - this article explains how...</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/findjobj-find-underlying-java-object/feed/</wfw:commentRss> <slash:comments>19</slash:comments> </item> <item><title>Detecting window focus events</title><link>http://undocumentedmatlab.com/blog/detecting-window-focus-events/</link> <comments>http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comments</comments> <pubDate>Wed, 09 Sep 2009 20:49:51 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Figure window]]></category> <category><![CDATA[GUI]]></category> <category><![CDATA[Hidden property]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[FindJObj]]></category> <category><![CDATA[JavaFrame]]></category> <category><![CDATA[UIInspect]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=584</guid> <description><![CDATA[Matlab does not have any documented method to detect window focus events (gain/loss). This article describes an undocumented way to detect such events.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/fixing-a-java-focus-problem/' rel='bookmark' title='Fixing a Java focus problem'>Fixing a Java focus problem</a> <small>Java components added to Matlab GUIs do not participate in the standard focus cycle - this article explains how to fix this problem....</small></li><li><a
href='http://undocumentedmatlab.com/blog/udd-events-and-listeners/' rel='bookmark' title='UDD Events and Listeners'>UDD Events and Listeners</a> <small>UDD event listeners can be used to listen to property value changes and other important events of Matlab objects...</small></li><li><a
href='http://undocumentedmatlab.com/blog/matlab-callbacks-for-java-events/' rel='bookmark' title='Matlab callbacks for Java events'>Matlab callbacks for Java events</a> <small>Events raised in Java code can be caught and handled in Matlab callback functions - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/disable-entire-figure-window/' rel='bookmark' title='Enable/disable entire figure window'>Enable/disable entire figure window</a> <small>Disabling/enabling an entire figure window is impossible with pure Matlab, but is very simple using the underlying Java. This article explains how....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>A CSSM reader <a
target="_blank rel="nofollow" href="http://www.mathworks.com/matlabcentral/newsreader/view_thread/260078#678945">recently asked</a> whether it is possible to detect window focus events (specifically, the focus-gain event) asynchronously, so that such events can trigger a callback without necessitating a polling thread to constantly monitor the windows state.</p><p>The user correctly mentioned the fact that although mouse-clicks within the window frame can be detected using the documented figure callback <b><i>WindowButtonDownFcn</i></b>, there are other methods by which a window can gain focus: keyboard (&lt;Alt&gt;-&lt;Tab&gt; on Windows, for example), clicking the window frame edge etc. These methods are all undetected by <b><i>WindowButtonDownFcn</i></b>.</p><p>This problem is, to the best of my knowledge, insoluble using standard documented Matlab. However, there is indeed a simple solution using undocumented/unsupported Matlab features. The solution relies on the fact that all Matlab windows are basically Java Swing objects, and these objects have dozens of standard callback hooks that can be utilized (Matlab only exposes a few callbacks). The list of standard Swing callbacks was detailed in my earlier article about <a
target="_blank" href="http://undocumentedmatlab.com/blog/uicontrol-callbacks/">uicontrol callbacks</a>, which is also relevant for Java window frames.</p><p>In this specific case, we are interested in <b><i>FocusGainedCallback</i></b>. This callback is invoked for the figure Frame&#8217;s AxisComponent (a part of the Frame that will be explained in another article). For each of our monitored figure windows, we set this callback to a predefined Matlab function. We may also wish to set its companion <b><i>FocusLostCallback</i></b>.</p><p>Here&#8217;s the resulting code snippet (hFig is our Matlab figure handle):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Prepare the figure</span>
hFig = <span style="color: #0000FF;">figure</span>;  <span style="color: #228B22;">% etc. - prepare the figure</span>
&nbsp;
<span style="color: #228B22;">% Get the underlying Java reference</span>
<span style="color: #0000FF;">warning</span> off MATLAB<span style="color: #F0F;">:</span>HandleGraphics<span style="color: #F0F;">:</span>ObsoletedProperty<span style="color: #F0F;">:</span>JavaFrame
jFig = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>hFig, <span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span>;
jAxis = jFig.<span style="">getAxisComponent</span>;
&nbsp;
<span style="color: #228B22;">% Set the focus event callback</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>jAxis,<span style="color:#A020F0;">'FocusGainedCallback'</span>,<span style="color: #080;">&#123;</span>@myMatlabFunc,hFig<span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>;
<span style="color: #228B22;">% perhaps also set the FocusLostCallback here</span></pre></div></div><p>Whenever any of the monitored figures now gets focus, by whichever means, the user-defined Matlab function myMatlabFunc() will be invoked. This function should be defined as follows:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">function</span> myMatlabFunc<span style="color: #080;">&#40;</span>jAxis, jEventData, hFig<span style="color: #080;">&#41;</span>
   <span style="color: #228B22;">% do whatever you wish with the event/hFig information</span>
<span style="color: #0000FF;">end</span></pre></div></div><p>Extra input parameters can be added during callback setup and definition, as follows:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>jAxis,<span style="color:#A020F0;">'FocusLostCallback'</span>,<span style="color: #080;">&#123;</span>@myMatlabFunc,hFig,data1,data2<span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>
<span style="color: #F0F;">...</span>
<span style="color: #0000FF;">function</span> myMatlabFunc<span style="color: #080;">&#40;</span>jAxis, jEventData, hFig, data1, data2<span style="color: #080;">&#41;</span>
   <span style="color: #228B22;">% do whatever you wish with the event/hFig/data information</span>
<span style="color: #0000FF;">end</span></pre></div></div><p>A very similar technique can detect other windowing events (maximization/minimization/movement etc.). Depending on the case, you may need to use <i>jFig.fFigureClient.getWindow</i> instead of <i>jFig.getAxisComponent</i>. The list of available callbacks for each of these objects can be seen using a simple <i><b>set</b>(jFig.getAxisComponent)</i> command, or via my <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/17935">UIInspect</a> or <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/14317">FindJObj</a> utilities on the Matlab File Exchange.</p><p>Note that all this relies on the undocumented hidden figure property <a
target="_blank" href="http://undocumentedmatlab.com/blog/tag/javaframe/"><b><i>JavaFrame</i></b></a>, which issues a standing warning (since Matlab release R2008a) of becoming obsolete in some future Matlab release. Since it worked so far, I have turned off this warning in the code above, but note that this code may well fail in some future Matlab version. If and when JavaFrame does become obsolete, be sure to look in this blog for workarounds&#8230;</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/fixing-a-java-focus-problem/' rel='bookmark' title='Fixing a Java focus problem'>Fixing a Java focus problem</a> <small>Java components added to Matlab GUIs do not participate in the standard focus cycle - this article explains how to fix this problem....</small></li><li><a
href='http://undocumentedmatlab.com/blog/udd-events-and-listeners/' rel='bookmark' title='UDD Events and Listeners'>UDD Events and Listeners</a> <small>UDD event listeners can be used to listen to property value changes and other important events of Matlab objects...</small></li><li><a
href='http://undocumentedmatlab.com/blog/matlab-callbacks-for-java-events/' rel='bookmark' title='Matlab callbacks for Java events'>Matlab callbacks for Java events</a> <small>Events raised in Java code can be caught and handled in Matlab callback functions - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/disable-entire-figure-window/' rel='bookmark' title='Enable/disable entire figure window'>Enable/disable entire figure window</a> <small>Disabling/enabling an entire figure window is impossible with pure Matlab, but is very simple using the underlying Java. This article explains how....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/detecting-window-focus-events/feed/</wfw:commentRss> <slash:comments>24</slash:comments> </item> <item><title>Setting status-bar components</title><link>http://undocumentedmatlab.com/blog/setting-status-bar-components/</link> <comments>http://undocumentedmatlab.com/blog/setting-status-bar-components/#comments</comments> <pubDate>Thu, 30 Jul 2009 10:09:10 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Figure window]]></category> <category><![CDATA[GUI]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[FindJObj]]></category> <category><![CDATA[JavaFrame]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=478</guid> <description><![CDATA[Matlab status-bars are Java containers in which we can add GUI controls such as progress-bars, not just simple text labels<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/setting-status-bar-text/' rel='bookmark' title='Setting status-bar text'>Setting status-bar text</a> <small>The Matlab desktop and figure windows have a usable statusbar which can only be set using undocumented methods. This post shows how to set the status-bar text....</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-line-position-in-edit-box-uicontrol/' rel='bookmark' title='Setting line position in an edit-box uicontrol'>Setting line position in an edit-box uicontrol</a> <small>Matlab uicontrols have many useful features that are only available via Java. Here's how to access them....</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-listbox-mouse-actions/' rel='bookmark' title='Setting listbox mouse actions'>Setting listbox mouse actions</a> <small>Matlab listbox uicontrol can be modified to detect mouse events for right-click context menus, dynamic tooltips etc....</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-system-tray-icons/' rel='bookmark' title='Setting system tray icons'>Setting system tray icons</a> <small>System-tray icons can be programmatically set and controlled from within Matlab, using new functionality available since R2007b....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>I last week&#8217;s post, <a
target="_blank" href="http://undocumentedmatlab.com/blog/setting-status-bar-text/">Setting status-bar text</a>, I showed how to set the status-bar text in Matlab figures and the main desktop. But Matlab status-bars are Java containers in which we can add GUI controls, not just simple text labels. In this post I will show how to do this for Matlab 7 figures.</p><p>Let&#8217;s return to the two alternatives I&#8217;ve presented in my previous post for setting a Matlab 7 figure status-bar text:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Alternative #1 (hFig = requested figure's handle)</span>
jFrame = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>hFig,<span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span>;
jFigPanel = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>jFrame,<span style="color:#A020F0;">'FigurePanelContainer'</span><span style="color: #080;">&#41;</span>;
jRootPane = jFigPanel.<span style="">getComponent</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>.<span style="">getRootPane</span>;
jRootPane = jRootPane.<span style="">getTopLevelAncestor</span>;
statusbarObj = jRootPane.<span style="">getStatusBar</span>;
statusbarObj.<span style="">setText</span><span style="color: #080;">&#40;</span>statusText<span style="color: #080;">&#41;</span>;
jRootPane.<span style="">setStatusBarVisible</span><span style="color: #080;">&#40;</span><span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Alternative #2</span>
jFrame = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>hFig,<span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span>;
jRootPane = jFrame.<span style="">fFigureClient</span>.<span style="">getWindow</span>;
statusbarObj = com.<span style="">mathworks</span>.<span style="">mwswing</span>.<span style="">MJStatusBar</span>;
jRootPane.<span style="">setStatusBar</span><span style="color: #080;">&#40;</span>statusbarObj<span style="color: #080;">&#41;</span>;
statusbarObj.<span style="">setText</span><span style="color: #080;">&#40;</span>statusText<span style="color: #080;">&#41;</span>;</pre></div></div><p>The first alternative uses the default status-bar (a com.mathworks.mwswing.MJStatusBar object) which Matlab automatically creates with each figure. This object is created as invisible, so we need to set its text (via its <i>setText</i> method), and then make it visible (via its ancestor&#8217;s root-pane&#8217;s <i>setStatusBarVisible</i> method &#8211; setting the object itself to visible is not enough). The alternative is to replace the default status-bar object with a user-specified container (in this case, we use a new instance of com.mathworks.mwswing.MJStatusBar).</p><p>Last week I forgot to mention that only the second alternative works in the general case &#8211; it appears that the first alternative often fails because figures are not created with the default statusbar on many platforms/Matlab release (I&#8217;m not sure exactly which). My <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/14773">StatusBar utility on the MathWorks File Exchange</a>, which I mentioned in last week&#8217;s post, takes care of these nuances, and automatically creates the status bar object if it is missing.</p><p>In any case, using these two code snippets as a baseline, we can customize any Java container that we wish. We are not limited to text labels. The default ststusbar container, MJStatusBar, only includes a single JLabel-derived component that stores the text message. We can add other components to this container. For example, let&#8217;s add a simple progress-bar:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jFrame = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>hFig,<span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span>;
jRootPane = jFrame.<span style="">fFigureClient</span>.<span style="">getWindow</span>;
statusbarObj = com.<span style="">mathworks</span>.<span style="">mwswing</span>.<span style="">MJStatusBar</span>;
&nbsp;
<span style="color: #228B22;">% Add a progress-bar to left side of standard MJStatusBar container</span>
jProgressBar = javax.<span style="">swing</span>.<span style="">JProgressBar</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>jProgressBar, <span style="color:#A020F0;">'Minimum'</span>,<span style="color: #33f;">0</span>, <span style="color:#A020F0;">'Maximum'</span>,<span style="color: #33f;">500</span>, <span style="color:#A020F0;">'Value'</span>,<span style="color: #33f;">234</span><span style="color: #080;">&#41;</span>;
statusbarObj.<span style="">add</span><span style="color: #080;">&#40;</span>jProgressBar,<span style="color:#A020F0;">'West'</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% 'West' =&gt; left of text; 'East' =&gt; right</span>
<span style="color: #228B22;">% Beware: 'East' also works but doesn't resize automatically</span>
&nbsp;
<span style="color: #228B22;">% Set this container as the figure's status-bar</span>
jRootPane.<span style="">setStatusBar</span><span style="color: #080;">&#40;</span>statusbarObj<span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Note: setting setStatusBarVisible(1) is not enough to display the status-bar</span>
<span style="color: #228B22;">% - we also need to call setText(), even if only with an empty string ''</span>
statusbarObj.<span style="">setText</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'testing 123...'</span><span style="color: #080;">&#41;</span>;
jRootPane.<span style="">setStatusBarVisible</span><span style="color: #080;">&#40;</span><span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>;</pre></div></div><p><center><br
/><div
class="wp-caption aligncenter" style="width: 438px"><img
alt="Status bar with a simple progress-bar" src="http://undocumentedmatlab.com/images/statusbar6a.png" title="Status bar with a simple progress-bar" width="428" height="271" /><p
class="wp-caption-text">Status bar with a simple progress-bar</p></div><br
/></center></p><p>We can of course use the progress-bar and status-bar handles to modify their appearance within our code, for example within some loop. For example:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">numIds = <span style="color: #0000FF;">length</span><span style="color: #080;">&#40;</span>allIds<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>jProgressBar, <span style="color:#A020F0;">'StringPainted'</span>,<span style="color:#A020F0;">'on'</span>, <span style="color:#A020F0;">'Maximum'</span>,numIds, <span style="color:#A020F0;">'Value'</span>,<span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">for</span> id = <span style="color: #33f;">1</span> <span style="color: #F0F;">:</span> numIds
&nbsp;
   <span style="color: #228B22;">% Update status bar</span>
   <span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>jProgressBar, <span style="color:#A020F0;">'StringPainted'</span>,<span style="color:#A020F0;">'on'</span>, <span style="color:#A020F0;">'Value'</span>,id<span style="color: #080;">&#41;</span>;
   msg = <span style="color:#A020F0;">'Processing %d of %d (%.1f%%)...'</span>;
   statusbarObj.<span style="">setText</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">sprintf</span><span style="color: #080;">&#40;</span>msg,id,numIds,<span style="color: #33f;">100</span>*id/numIds<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
&nbsp;
   <span style="color: #228B22;">% do something useful...</span>
&nbsp;
<span style="color: #0000FF;">end</span>  <span style="color: #228B22;">% for all Ids</span>
&nbsp;
<span style="color: #228B22;">% Some final status-bar updates...</span>
<span style="color: #228B22;">% Hide the progress-bar</span>
jProgressBar.<span style="">setVisible</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Hide the corner grip</span>
cornerGrip = statusbarObj.<span style="">getParent</span>.<span style="">getComponent</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>;
cornerGrip.<span style="">setVisible</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% or: set(cornerGrip,'Visible','off')</span>
&nbsp;
<span style="color: #228B22;">% Set a red foreground &amp; yellow background to status bar text</span>
statusbarObj.<span style="">setText</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'All done - congratulations!!!'</span><span style="color: #080;">&#41;</span>;
statusbarTxt = statusbarObj.<span style="">getComponent</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>;
statusbarTxt.<span style="">setForeground</span><span style="color: #080;">&#40;</span>java.<span style="">awt</span>.<span style="">Color</span>.<span style="">red</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>statusbarTxt,<span style="color:#A020F0;">'Background'</span>,<span style="color:#A020F0;">'yellow'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>statusbarTxt,<span style="color:#A020F0;">'Background'</span>,<span style="color: #080;">&#91;</span><span style="color: #33f;">1</span>,<span style="color: #33f;">1</span>,<span style="color: #33f;">0</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% an alternative…</span></pre></div></div><p><center><br
/><div
class="wp-caption aligncenter" style="width: 430px"><img
alt="Modifying status bar properties in run-timer" src="http://undocumentedmatlab.com/images/statusbar_animated.gif" title="Modifying status bar properties in run-time" width="420" height="266" /><p
class="wp-caption-text">Modifying status bar properties in run-time</p></div><br
/></center></p><p>The progress-bar component was just a simple example of how to present non-intrusive controls/information in the figure status bar. Other controls (buttons, checkboxes etc.) can similarly be added.</p><p>Note that the status-bar&#8217;s corner-grip (at its far right) is not a sub-component of the statusbarObj object like the label, but rather of its parent JPanel container. This is easily be seen using my <a
target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/14317" rel="nofollow">FindJObj utility on the MathWorks File Exchange</a>:</p><p><center><br
/><div
class="wp-caption aligncenter" style="width: 430px"><img
alt="Status bar with a simple progress-bar" src="http://undocumentedmatlab.com/images/statusbar6d2.png" title="Status bar components hierarchy" width="420" height="509" /><p
class="wp-caption-text">Status bar with a simple progress-bar</p></div><br
/></center></p><p>One final note: The status bar is 20 pixels high across the entire bottom of the figure. It hides everything between pixel heights 0-20, even parts of uicontrols, regardless of who was created first or the relative ComponentZOrder in the frame&#8217;s ContentPane:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Add a &quot;Next phase&quot; button to the right of the text</span>
jb = javax.<span style="">swing</span>.<span style="">JButton</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Next phase &gt;'</span><span style="color: #080;">&#41;</span>;
jbh = handle<span style="color: #080;">&#40;</span>jb,<span style="color:#A020F0;">'CallbackProperties'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>jbh, <span style="color:#A020F0;">'ActionPerformedCallback'</span>, @nextPhaseFunction<span style="color: #080;">&#41;</span>;
statusbarObj.<span style="">add</span><span style="color: #080;">&#40;</span>jb,<span style="color:#A020F0;">'East'</span><span style="color: #080;">&#41;</span>;
<span style="color: #228B22;">%note: we might need jRootPane.setStatusBarVisible(0)</span>
<span style="color: #228B22;">% followed by jRootPane.setStatusBarVisible(1) to repaint</span>
&nbsp;
<span style="color: #228B22;">% Add a simple Matlab uicontrol, obscured by the status-bar</span>
hb = <span style="color: #0000FF;">uicontrol</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'string'</span>,<span style="color:#A020F0;">'click me!'</span>, <span style="color:#A020F0;">'position'</span>,<span style="color: #080;">&#91;</span><span style="color: #33f;">10</span>,<span style="color: #33f;">15</span>,<span style="color: #33f;">70</span>,<span style="color: #33f;">30</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>;</pre></div></div><p><center><br
/><div
class="wp-caption aligncenter" style="width: 438px"><img
alt="Adding controls inside and outside the status-bar" src="http://undocumentedmatlab.com/images/statusbar6e.png" title="Adding controls inside and outside the status-bar" width="428" height="244" /><p
class="wp-caption-text">Adding controls inside and outside the status-bar</p></div><br
/></center></p><p>If you have made interesting use of Matlab&#8217;s status-bar, please share them in the comments section below.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/setting-status-bar-text/' rel='bookmark' title='Setting status-bar text'>Setting status-bar text</a> <small>The Matlab desktop and figure windows have a usable statusbar which can only be set using undocumented methods. This post shows how to set the status-bar text....</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-line-position-in-edit-box-uicontrol/' rel='bookmark' title='Setting line position in an edit-box uicontrol'>Setting line position in an edit-box uicontrol</a> <small>Matlab uicontrols have many useful features that are only available via Java. Here's how to access them....</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-listbox-mouse-actions/' rel='bookmark' title='Setting listbox mouse actions'>Setting listbox mouse actions</a> <small>Matlab listbox uicontrol can be modified to detect mouse events for right-click context menus, dynamic tooltips etc....</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-system-tray-icons/' rel='bookmark' title='Setting system tray icons'>Setting system tray icons</a> <small>System-tray icons can be programmatically set and controlled from within Matlab, using new functionality available since R2007b....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/setting-status-bar-components/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> </channel> </rss>

<!-- W3 Total Cache: Minify debug info:
Engine:             disk: basic
Theme:              b7666
Template:           tag
-->
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: undocumentedmatlab.com @ 2012-05-21 20:07:46 -->

<!-- W3 Total Cache: Page cache debug info:
Engine:             disk: enhanced
Cache key:          blog/tag/javaframe/feed/_index.xml_gzip
Caching:            enabled
Status:             not cached
Creation Time:      2.275s
Header info:
X-Pingback:         http://undocumentedmatlab.com/blog/xmlrpc.php
Set-Cookie:         wpgb_visit_last_php-default=1337656065; expires=Wed, 22-May-2013 03:07:45 GMT; path=/
Content-Type:       text/xml; charset=UTF-8
Last-Modified:      Tue, 22 May 2012 03:07:46 GMT
Vary:               Accept-Encoding, Cookie
Expires:            Tue, 22 May 2012 04:07:46 GMT
Pragma:             public
Cache-Control:      public, must-revalidate, proxy-revalidate
Etag:               cbdd7adfcea0f340c4d7098fb0179c0e
Content-Encoding:   gzip
-->
