<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Uitab colors, icons and images	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/uitab-colors-icons-images/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/uitab-colors-icons-images?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=uitab-colors-icons-images</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Thu, 15 Feb 2024 14:34:43 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>
		By: Niko		</title>
		<link>https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-523620</link>

		<dc:creator><![CDATA[Niko]]></dc:creator>
		<pubDate>Thu, 15 Feb 2024 14:34:43 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=1955#comment-523620</guid>

					<description><![CDATA[&lt;code&gt;jTabGroup = getappdata(handle(hTabGroup),&#039;JTabbedPane&#039;);&lt;/code&gt;
doesn&#039;t work anymore in R2023b :(

when i do 
&lt;code&gt;jTabGroup = findjobj(hTabGroup,&#039;class&#039;,&#039;MJTabbedPane&#039;);&lt;/code&gt;

I get an object of class
javahandle_withcallbacks.com.mathworks.mwswing.MJTabbedPane

But when I call e.g.
&lt;code&gt;jTabGroup.setForegroundAt(0,java.awt.Color(1.0,1,1));&lt;/code&gt;

on it, I just get
&quot;Incorrect number or types of inputs or outputs for function setForegroundAt.&quot;]]></description>
			<content:encoded><![CDATA[<p><code>jTabGroup = getappdata(handle(hTabGroup),'JTabbedPane');</code><br />
doesn&#8217;t work anymore in R2023b 🙁</p>
<p>when i do<br />
<code>jTabGroup = findjobj(hTabGroup,'class','MJTabbedPane');</code></p>
<p>I get an object of class<br />
javahandle_withcallbacks.com.mathworks.mwswing.MJTabbedPane</p>
<p>But when I call e.g.<br />
<code>jTabGroup.setForegroundAt(0,java.awt.Color(1.0,1,1));</code></p>
<p>on it, I just get<br />
&#8220;Incorrect number or types of inputs or outputs for function setForegroundAt.&#8221;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Peter		</title>
		<link>https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-512169</link>

		<dc:creator><![CDATA[Peter]]></dc:creator>
		<pubDate>Tue, 09 Nov 2021 09:50:22 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=1955#comment-512169</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-512159&quot;&gt;Yair Altman&lt;/a&gt;.

It&#039;s working! THANK YOU!!]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-512159">Yair Altman</a>.</p>
<p>It&#8217;s working! THANK YOU!!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-512159</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Mon, 08 Nov 2021 20:23:38 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=1955#comment-512159</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-512158&quot;&gt;Peter&lt;/a&gt;.

@Peter - tab heights are set by the Operating System&#039;s Look and Feel. You can either &lt;a href=&quot;http://undocumentedmatlab.com/articles/modifying-matlab-look-and-feel&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;change the Look-and-Feel used by Matlab&lt;/a&gt;, or use the much larger tabs in the &lt;a href=&quot;https://www.mathworks.com/matlabcentral/fileexchange/27758-gui-layout-toolbox&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;GUI Layout Toolbox (GUILT)&lt;/a&gt;.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-512158">Peter</a>.</p>
<p>@Peter &#8211; tab heights are set by the Operating System&#8217;s Look and Feel. You can either <a href="http://undocumentedmatlab.com/articles/modifying-matlab-look-and-feel" rel="nofollow" target="_blank">change the Look-and-Feel used by Matlab</a>, or use the much larger tabs in the <a href="https://www.mathworks.com/matlabcentral/fileexchange/27758-gui-layout-toolbox" target="_blank" rel="nofollow">GUI Layout Toolbox (GUILT)</a>.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Peter		</title>
		<link>https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-512158</link>

		<dc:creator><![CDATA[Peter]]></dc:creator>
		<pubDate>Mon, 08 Nov 2021 19:53:08 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=1955#comment-512158</guid>

					<description><![CDATA[Hello again Mr. Altman and thank you for all you work and help!
I have a question. I want to resize the TABS, i mean the small things at the top, that says &quot;tab1, tab2,....&quot; they are incredible small. I searched an eternity for a solution but cant find it. I tried fontsize and jLabel size but they are not resizing. They stay in a fixed height. the width is stretching accordingly to the amount of text but not the height itself. Do you know a solution? I am working with Matlab 2013b.
Greetings
Peter]]></description>
			<content:encoded><![CDATA[<p>Hello again Mr. Altman and thank you for all you work and help!<br />
I have a question. I want to resize the TABS, i mean the small things at the top, that says &#8220;tab1, tab2,&#8230;.&#8221; they are incredible small. I searched an eternity for a solution but cant find it. I tried fontsize and jLabel size but they are not resizing. They stay in a fixed height. the width is stretching accordingly to the amount of text but not the height itself. Do you know a solution? I am working with Matlab 2013b.<br />
Greetings<br />
Peter</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-496697</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Tue, 10 Sep 2019 10:32:02 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=1955#comment-496697</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-494420&quot;&gt;Michi&lt;/a&gt;.

@Michi - in recent Matlab releases Matlab no longer stores the Java handle in the tab-group&#039;s &lt;b&gt;ApplicationData&lt;/b&gt; property, so using &lt;i&gt;&lt;b&gt;getappdata()&lt;/b&gt;&lt;/i&gt; returns an empty array, causing the error that you see. Instead of using &lt;i&gt;&lt;b&gt;getappdata&lt;/b&gt;&lt;/i&gt;, us the &lt;a href=&quot;http://undocumentedmatlab.com/blog/findjobj-find-underlying-java-object&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;&lt;i&gt;&lt;b&gt;findjobj&lt;/b&gt;&lt;/i&gt; utility&lt;/a&gt;:
&lt;pre lang=&quot;matlab&quot;&gt;jTabGroup = findjobj(hTabGroup,&#039;class&#039;,&#039;MJTabbedPane&#039;);&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-494420">Michi</a>.</p>
<p>@Michi &#8211; in recent Matlab releases Matlab no longer stores the Java handle in the tab-group&#8217;s <b>ApplicationData</b> property, so using <i><b>getappdata()</b></i> returns an empty array, causing the error that you see. Instead of using <i><b>getappdata</b></i>, us the <a href="http://undocumentedmatlab.com/blog/findjobj-find-underlying-java-object" target="_blank" rel="nofollow"><i><b>findjobj</b></i> utility</a>:</p>
<pre lang="matlab">jTabGroup = findjobj(hTabGroup,'class','MJTabbedPane');</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Michi		</title>
		<link>https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-494420</link>

		<dc:creator><![CDATA[Michi]]></dc:creator>
		<pubDate>Thu, 29 Aug 2019 17:13:43 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=1955#comment-494420</guid>

					<description><![CDATA[Hi Yair, 
many thanks for the excellent and very interesting work arounds! I am currently struggling with the example you provided. When I run your code  

&lt;pre lang=&quot;matlab&quot;&gt;
% Prevent an annoying warning msg
warning off MATLAB:uitabgroup:OldVersion
 
% Prepare a tab-group consisting of two tabs
hTabGroup = uitabgroup; drawnow;
tab1 = uitab(hTabGroup, &#039;title&#039;,&#039;Panel 1&#039;);
a = axes(&#039;parent&#039;, tab1); surf(peaks);
tab2 = uitab(hTabGroup, &#039;title&#039;,&#039;Panel 2&#039;);
uicontrol(tab2, &#039;String&#039;,&#039;Close&#039;, &#039;Callback&#039;,&#039;close(gcbf)&#039;);
 
% Get the underlying Java reference (use hidden property)
jTabGroup = getappdata(handle(hTabGroup),&#039;JTabbedPane&#039;);

% Equivalent manners to set a red tab foreground:
jTabGroup.setForegroundAt(1,java.awt.Color(1.0,0,0)); % tab #1
jTabGroup.setTitleAt(1,&#039;&lt;i&gt;Panel 2&#039;);
jTabGroup.setForeground(java.awt.Color.red);

% Equivalent manners to set a yellow tab background:
jTabGroup.setTitleAt(0,&#039;Panel 1&#039;);
jTabGroup.setTitleAt(0,&#039;Panel 1&#039;);
&lt;/pre&gt;

the following error shows up:
Dot indexing is not supported for variables of this type.

Executing your code line by line indicates that the error is prompted for the first time when executing
jTabGroup.setForegroundAt(1,java.awt.Color(1.0,0,0)); % tab #1

I am using MATLAB Version: 9.5.0.1033004 (R2018b) Update 2.

Many thanks for your help!]]></description>
			<content:encoded><![CDATA[<p>Hi Yair,<br />
many thanks for the excellent and very interesting work arounds! I am currently struggling with the example you provided. When I run your code  </p>
<pre lang="matlab">
% Prevent an annoying warning msg
warning off MATLAB:uitabgroup:OldVersion
 
% Prepare a tab-group consisting of two tabs
hTabGroup = uitabgroup; drawnow;
tab1 = uitab(hTabGroup, 'title','Panel 1');
a = axes('parent', tab1); surf(peaks);
tab2 = uitab(hTabGroup, 'title','Panel 2');
uicontrol(tab2, 'String','Close', 'Callback','close(gcbf)');
 
% Get the underlying Java reference (use hidden property)
jTabGroup = getappdata(handle(hTabGroup),'JTabbedPane');

% Equivalent manners to set a red tab foreground:
jTabGroup.setForegroundAt(1,java.awt.Color(1.0,0,0)); % tab #1
jTabGroup.setTitleAt(1,'<i>Panel 2');
jTabGroup.setForeground(java.awt.Color.red);

% Equivalent manners to set a yellow tab background:
jTabGroup.setTitleAt(0,'Panel 1');
jTabGroup.setTitleAt(0,'Panel 1');
</i></pre>
<p>the following error shows up:<br />
Dot indexing is not supported for variables of this type.</p>
<p>Executing your code line by line indicates that the error is prompted for the first time when executing<br />
jTabGroup.setForegroundAt(1,java.awt.Color(1.0,0,0)); % tab #1</p>
<p>I am using MATLAB Version: 9.5.0.1033004 (R2018b) Update 2.</p>
<p>Many thanks for your help!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Thomas		</title>
		<link>https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-423660</link>

		<dc:creator><![CDATA[Thomas]]></dc:creator>
		<pubDate>Fri, 20 Apr 2018 12:09:14 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=1955#comment-423660</guid>

					<description><![CDATA[Hi Yair,

when I run your code:
&lt;pre lang=&quot;matlab&quot;&gt;
figure 
% Prepare a tab-group consisting of two tabs
hTabGroup = uitabgroup; drawnow;
tab1 = uitab(hTabGroup, &#039;title&#039;,&#039;Panel 1&#039;);
a = axes(&#039;parent&#039;, tab1); surf(peaks);
tab2 = uitab(hTabGroup, &#039;title&#039;,&#039;Panel 2&#039;);
uicontrol(tab2, &#039;String&#039;,&#039;Close&#039;, &#039;Callback&#039;,&#039;close(gcbf)&#039;);
 
% Get the underlying Java reference (use hidden property)
jTabGroup = getappdata(handle(hTabGroup),&#039;JTabbedPane&#039;);
 
% Add an icon to tab #1 (=second tab)
icon = javax.swing.ImageIcon(&#039;Find.gif&#039;);
jLabel = javax.swing.JLabel(&#039;Tab #2&#039;);
jLabel.setIcon(icon);
jTabGroup.setTabComponentAt(1,jLabel);	% Tab #1 = second tab
 
% Note: both label &amp; icon automatically grayed when disabled
jTabGroup.setEnabledAt(1,false);  % disable only tab #1
&lt;/pre&gt;
I get the following error message. Can you tell me what&#039;s wrong? or Would you please send me your code that works fine?

Thanks,
Maz]]></description>
			<content:encoded><![CDATA[<p>Hi Yair,</p>
<p>when I run your code:</p>
<pre lang="matlab">
figure 
% Prepare a tab-group consisting of two tabs
hTabGroup = uitabgroup; drawnow;
tab1 = uitab(hTabGroup, 'title','Panel 1');
a = axes('parent', tab1); surf(peaks);
tab2 = uitab(hTabGroup, 'title','Panel 2');
uicontrol(tab2, 'String','Close', 'Callback','close(gcbf)');
 
% Get the underlying Java reference (use hidden property)
jTabGroup = getappdata(handle(hTabGroup),'JTabbedPane');
 
% Add an icon to tab #1 (=second tab)
icon = javax.swing.ImageIcon('Find.gif');
jLabel = javax.swing.JLabel('Tab #2');
jLabel.setIcon(icon);
jTabGroup.setTabComponentAt(1,jLabel);	% Tab #1 = second tab
 
% Note: both label &#038; icon automatically grayed when disabled
jTabGroup.setEnabledAt(1,false);  % disable only tab #1
</pre>
<p>I get the following error message. Can you tell me what&#8217;s wrong? or Would you please send me your code that works fine?</p>
<p>Thanks,<br />
Maz</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-422357</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Thu, 05 Apr 2018 15:05:48 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=1955#comment-422357</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-422205&quot;&gt;Eric&lt;/a&gt;.

@Eric - HTML alignments only work within the area that the control allocates for the contents. It so happens that Java Swing allocates a tightly-fitting area for controls, so we basically have 3 options:
&lt;ul&gt;
	&lt;li&gt;Use a fixed-width font and right-pad with spaces&lt;/li&gt;
	&lt;li&gt;Get the underlying Java handle of the tab-group and modify the Java properties (this became very difficult in recent Matlab releases)&lt;/li&gt;
	&lt;li&gt;Enlarge the allocated area dynamically via pure Matlab and HTML: We first get the width of the tabs, then we set the tab&#039;s title to be a left-aligned table having the same fixed width as the tab (minus a bit due to the margins):
&lt;pre lang=&quot;matlab&quot;&gt;
pos = getpixelposition(tab1);
tab1.Title = sprintf(&#039;&lt;html&gt;&lt;table align=left width=%d&gt;Tab #1&#039;, pos(1)-4);
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-422205">Eric</a>.</p>
<p>@Eric &#8211; HTML alignments only work within the area that the control allocates for the contents. It so happens that Java Swing allocates a tightly-fitting area for controls, so we basically have 3 options:</p>
<ul>
<li>Use a fixed-width font and right-pad with spaces</li>
<li>Get the underlying Java handle of the tab-group and modify the Java properties (this became very difficult in recent Matlab releases)</li>
<li>Enlarge the allocated area dynamically via pure Matlab and HTML: We first get the width of the tabs, then we set the tab&#8217;s title to be a left-aligned table having the same fixed width as the tab (minus a bit due to the margins):
<pre lang="matlab">
pos = getpixelposition(tab1);
tab1.Title = sprintf('<html><table align=left width=%d>Tab #1', pos(1)-4);
</table></html></pre>
</li>
</ul>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Eric		</title>
		<link>https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-422205</link>

		<dc:creator><![CDATA[Eric]]></dc:creator>
		<pubDate>Wed, 04 Apr 2018 17:11:40 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=1955#comment-422205</guid>

					<description><![CDATA[Yair,
I have a tab group positioned on the left using TabLocation and i am ok with the auto-sizing of the tabs to fit the longest tab name, but for all the tab names i would like them left justified. Trying to do this by setting the title property of the tab using an HTML string doesn&#039;t seem to work. Is there a work around for this? Example code below:

&lt;pre lang=&quot;matlab&quot;&gt;
hTabGroup2 = uitabgroup;
tab1 = uitab(hTabGroup2,&#039;title&#039;,&#039;Tab #1&#039;);
tab2 = uitab(hTabGroup2,&#039;title&#039;,&#039;This is a very long tab&#039;);
tab3 = uitab(hTabGroup2,&#039;title&#039;,&#039;Tab #3&#039;);
set(hTabGroup2,&#039;TabLocation&#039;,&#039;left&#039;)

set(tab1,&#039;Title&#039;,&#039;Tab #1&#039;)
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>Yair,<br />
I have a tab group positioned on the left using TabLocation and i am ok with the auto-sizing of the tabs to fit the longest tab name, but for all the tab names i would like them left justified. Trying to do this by setting the title property of the tab using an HTML string doesn&#8217;t seem to work. Is there a work around for this? Example code below:</p>
<pre lang="matlab">
hTabGroup2 = uitabgroup;
tab1 = uitab(hTabGroup2,'title','Tab #1');
tab2 = uitab(hTabGroup2,'title','This is a very long tab');
tab3 = uitab(hTabGroup2,'title','Tab #3');
set(hTabGroup2,'TabLocation','left')

set(tab1,'Title','Tab #1')
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-415546</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Thu, 26 Oct 2017 16:40:00 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=1955#comment-415546</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-415542&quot;&gt;Dani&lt;/a&gt;.

@Dani - it works fine for me - perhaps your specific GUI has a problem that causes a problem for findjobj to find the underlying java handle:
&lt;pre lang=&quot;matlab&quot;&gt;
jHandles = findjobj(hTabGroup);
jTabbedPane = jHandles(end);
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/uitab-colors-icons-images#comment-415542">Dani</a>.</p>
<p>@Dani &#8211; it works fine for me &#8211; perhaps your specific GUI has a problem that causes a problem for findjobj to find the underlying java handle:</p>
<pre lang="matlab">
jHandles = findjobj(hTabGroup);
jTabbedPane = jHandles(end);
</pre>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
