<?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: Button customization	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/button-customization/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/button-customization?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=button-customization</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Tue, 17 Nov 2020 04:46:04 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>
		By: Kim		</title>
		<link>https://undocumentedmatlab.com/articles/button-customization#comment-509255</link>

		<dc:creator><![CDATA[Kim]]></dc:creator>
		<pubDate>Tue, 17 Nov 2020 04:46:04 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=184#comment-509255</guid>

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

Yair, the following didn&#039;t work for me either:

jh.setBorderPainted(false);

Regards,
Kim]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/button-customization#comment-352617">Yair Altman</a>.</p>
<p>Yair, the following didn&#8217;t work for me either:</p>
<p>jh.setBorderPainted(false);</p>
<p>Regards,<br />
Kim</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/button-customization#comment-508132</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Tue, 21 Jan 2020 08:31:27 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=184#comment-508132</guid>

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

The default Java Look&amp;Feel for UI buttons paints the border together with the contents, and apparently prevents changing both of them together (&lt;a href=&quot;https://stackoverflow.com/questions/41990547/change-color-of-jbutton-without-changing-its-shape&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;reference&lt;/a&gt;). &lt;a href=&quot;http://undocumentedmatlab.com/articles/modifying-matlab-look-and-feel&quot; target=&quot;_blank&quot;&gt;Changing to a different Look&amp;Feel&lt;/a&gt; might possibly help, and of course you could always create and use a custom Java class that inherits &lt;code&gt;JButton&lt;/code&gt;. In any case, this is a pure Java Swing issue (not Matlab) so you should search for answers in Java forums.

Cross-reference: http://undocumentedmatlab.com/articles/customizing-uicontrol-border]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/button-customization#comment-508131">Jacob</a>.</p>
<p>The default Java Look&#038;Feel for UI buttons paints the border together with the contents, and apparently prevents changing both of them together (<a href="https://stackoverflow.com/questions/41990547/change-color-of-jbutton-without-changing-its-shape" target="_blank" rel="nofollow">reference</a>). <a href="http://undocumentedmatlab.com/articles/modifying-matlab-look-and-feel" target="_blank">Changing to a different Look&#038;Feel</a> might possibly help, and of course you could always create and use a custom Java class that inherits <code>JButton</code>. In any case, this is a pure Java Swing issue (not Matlab) so you should search for answers in Java forums.</p>
<p>Cross-reference: <a href="http://undocumentedmatlab.com/articles/customizing-uicontrol-border" rel="ugc">http://undocumentedmatlab.com/articles/customizing-uicontrol-border</a></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jacob		</title>
		<link>https://undocumentedmatlab.com/articles/button-customization#comment-508131</link>

		<dc:creator><![CDATA[Jacob]]></dc:creator>
		<pubDate>Mon, 20 Jan 2020 23:01:04 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=184#comment-508131</guid>

					<description><![CDATA[So, I&#039;m having trouble finding information on this.

If I change the border of a button, then change the background color, the border resets. Then I am not able to change the border whatsoever. Is there a way I can change the border and the background? I do not want to be stuck using borderless buttons if I don&#039;t have to

Thanks]]></description>
			<content:encoded><![CDATA[<p>So, I&#8217;m having trouble finding information on this.</p>
<p>If I change the border of a button, then change the background color, the border resets. Then I am not able to change the border whatsoever. Is there a way I can change the border and the background? I do not want to be stuck using borderless buttons if I don&#8217;t have to</p>
<p>Thanks</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/button-customization#comment-374832</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Fri, 22 Apr 2016 09:59:50 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=184#comment-374832</guid>

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

@David - you can place the relevant &lt;code&gt;setIcon()&lt;/code&gt; code in a small function and set the parent&#039;s &lt;b&gt;SizeChangedFcn&lt;/b&gt; callback to this function&#039;s handle. This way whenever the parent resizes the icon will get repainted. Add a call to &lt;code&gt;jButton.repaint()&lt;/code&gt; after &lt;code&gt;setIcon()&lt;/code&gt;, to ensure that it actually gets repainted.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/button-customization#comment-374387">David</a>.</p>
<p>@David &#8211; you can place the relevant <code>setIcon()</code> code in a small function and set the parent&#8217;s <b>SizeChangedFcn</b> callback to this function&#8217;s handle. This way whenever the parent resizes the icon will get repainted. Add a call to <code>jButton.repaint()</code> after <code>setIcon()</code>, to ensure that it actually gets repainted.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: David		</title>
		<link>https://undocumentedmatlab.com/articles/button-customization#comment-374387</link>

		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Thu, 14 Apr 2016 23:10:20 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=184#comment-374387</guid>

					<description><![CDATA[Hi Yair, 
First of all thanks for this great site.
I have a problem when resizing the button parent window, the icon image dissappears.
&lt;pre lang=&quot;matlab&quot;&gt;
f = figure;
b = uicontrol(f);
jButton = java(findjobj(b))
jButton.setIcon(javax.swing.ImageIcon(iconPath))
&lt;/pre&gt;
I am using R2015a and Windows7]]></description>
			<content:encoded><![CDATA[<p>Hi Yair,<br />
First of all thanks for this great site.<br />
I have a problem when resizing the button parent window, the icon image dissappears.</p>
<pre lang="matlab">
f = figure;
b = uicontrol(f);
jButton = java(findjobj(b))
jButton.setIcon(javax.swing.ImageIcon(iconPath))
</pre>
<p>I am using R2015a and Windows7</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/button-customization#comment-352617</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Tue, 07 Jul 2015 18:37:28 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=184#comment-352617</guid>

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

@Brian - &lt;pre lang=&#039;matlab&#039;&gt;jh.setBorderPainted(false);  % or: jh.BorderPainted=false;&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/button-customization#comment-352195">Brian</a>.</p>
<p>@Brian &#8211; </p>
<pre lang='matlab'>jh.setBorderPainted(false);  % or: jh.BorderPainted=false;</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Brian		</title>
		<link>https://undocumentedmatlab.com/articles/button-customization#comment-352195</link>

		<dc:creator><![CDATA[Brian]]></dc:creator>
		<pubDate>Wed, 01 Jul 2015 09:11:09 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=184#comment-352195</guid>

					<description><![CDATA[Hello Yair,
Thanks for all your work on this site.

I&#039;ve had a heck of a time trying to figure out how to do a border-less button. I tried using both the null vector &#039;[]&#039; approach and by setting the border directly by using the methods from the border factory class  from the link you posted above (see below). However none of these attempts result in a border-less button.

I followed your example of a borderless button from here:
http://undocumentedmatlab.com/blog/borderless-button-used-for-plot-properties


I just can&#039;t understand why this won&#039;t work here in this simplified example. My simple code looks like this so far:
&lt;pre lang=&quot;matlab&quot;&gt;
f=figure(&#039;Menubar&#039;,&#039;none&#039;, &#039;Position&#039;,[200 200 300 200]);
p=uipanel(f, &#039;BackgroundColor&#039;, [0 0 1]);
h = uicontrol(&#039;parent&#039;, p, &#039;Style&#039;,&#039;pushbutton&#039;, &#039;String&#039;,&#039;click&#039;, ...
   &#039;Units&#039;,&#039;normalized&#039;, &#039;Position&#039;,[0.3 0.3 0.5 0.5],&#039;BackgroundColor&#039;, [0 0 1]);
jh = findjobj(h);
jh.setBorder(javax.swing.BorderFactory.createEmptyBorder()); %attempt 1 does not remove border
jh.border=[];                                                %attempt 2 does not remove border
jh.setBorder([]);                                            %attempt 3 does not remove border
jh.border=javax.swing.BorderFactory.createEmptyBorder();     %attempt 4 does not remove border
&lt;/pre&gt;

I&#039;m using MATLAB 2015a and Windows7. Any way you can provide a simple complete code for a border-less button or edit above?

Thank You!]]></description>
			<content:encoded><![CDATA[<p>Hello Yair,<br />
Thanks for all your work on this site.</p>
<p>I&#8217;ve had a heck of a time trying to figure out how to do a border-less button. I tried using both the null vector &#8216;[]&#8217; approach and by setting the border directly by using the methods from the border factory class  from the link you posted above (see below). However none of these attempts result in a border-less button.</p>
<p>I followed your example of a borderless button from here:<br />
<a href="http://undocumentedmatlab.com/blog/borderless-button-used-for-plot-properties" rel="ugc">http://undocumentedmatlab.com/blog/borderless-button-used-for-plot-properties</a></p>
<p>I just can&#8217;t understand why this won&#8217;t work here in this simplified example. My simple code looks like this so far:</p>
<pre lang="matlab">
f=figure('Menubar','none', 'Position',[200 200 300 200]);
p=uipanel(f, 'BackgroundColor', [0 0 1]);
h = uicontrol('parent', p, 'Style','pushbutton', 'String','click', ...
   'Units','normalized', 'Position',[0.3 0.3 0.5 0.5],'BackgroundColor', [0 0 1]);
jh = findjobj(h);
jh.setBorder(javax.swing.BorderFactory.createEmptyBorder()); %attempt 1 does not remove border
jh.border=[];                                                %attempt 2 does not remove border
jh.setBorder([]);                                            %attempt 3 does not remove border
jh.border=javax.swing.BorderFactory.createEmptyBorder();     %attempt 4 does not remove border
</pre>
<p>I&#8217;m using MATLAB 2015a and Windows7. Any way you can provide a simple complete code for a border-less button or edit above?</p>
<p>Thank You!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Cristiano		</title>
		<link>https://undocumentedmatlab.com/articles/button-customization#comment-351547</link>

		<dc:creator><![CDATA[Cristiano]]></dc:creator>
		<pubDate>Fri, 19 Jun 2015 01:59:46 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=184#comment-351547</guid>

					<description><![CDATA[Hello, Yair.
The methods you mention is useful，however，when I zoomed the window I found the Icon was overlapped by the String.  Finally，If I let a dialog or form have a FIXED size，the problem is solved. I intended to resize dialogs or forms in the Windows without overlapping the Icon, but I didn&#039;t handle it.
&lt;pre lang=&quot;matlab&quot;&gt; 
info_icon_path = fullfile(&#039;C:\Users\Zhang\Desktop\icons\ModelAdvisor.png&#039;);
info_aSi = uicontrol(&#039;Style&#039;,&#039;PushButton&#039;,...   
                 &#039;position&#039;,[10,10,120,70],...
                 &#039;TooltipString&#039;,&#039;&#039;,...  
                 &#039;fontsize&#039;,10,...      
                 &#039;fontweight&#039;,&#039;bold&#039;,...      
                 &#039;String&#039;,&#039;Description&#039;,...
                 &#039;Enable&#039;,&#039;on&#039;);

jButton_info_nFS = findjobj(info_aSi);              %find Java-Handle of Button
jButton_info_nFS.setIcon(javax.swing.ImageIcon(info_icon_path));    %add image to button
set(jButton_info_nFS,&#039;HorizontalTextPosition&#039;,javax.swing.SwingConstants.RIGHT);    %align text
set(jButton_info_nFS,&#039;VerticalTextPosition&#039;,javax.swing.SwingConstants.CENTER);   
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>Hello, Yair.<br />
The methods you mention is useful，however，when I zoomed the window I found the Icon was overlapped by the String.  Finally，If I let a dialog or form have a FIXED size，the problem is solved. I intended to resize dialogs or forms in the Windows without overlapping the Icon, but I didn&#8217;t handle it.</p>
<pre lang="matlab"> 
info_icon_path = fullfile('C:\Users\Zhang\Desktop\icons\ModelAdvisor.png');
info_aSi = uicontrol('Style','PushButton',...   
                 'position',[10,10,120,70],...
                 'TooltipString','',...  
                 'fontsize',10,...      
                 'fontweight','bold',...      
                 'String','Description',...
                 'Enable','on');

jButton_info_nFS = findjobj(info_aSi);              %find Java-Handle of Button
jButton_info_nFS.setIcon(javax.swing.ImageIcon(info_icon_path));    %add image to button
set(jButton_info_nFS,'HorizontalTextPosition',javax.swing.SwingConstants.RIGHT);    %align text
set(jButton_info_nFS,'VerticalTextPosition',javax.swing.SwingConstants.CENTER);   
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Chris		</title>
		<link>https://undocumentedmatlab.com/articles/button-customization#comment-318726</link>

		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Fri, 14 Mar 2014 17:14:48 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=184#comment-318726</guid>

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

OK, thanks.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/button-customization#comment-318611">Yair Altman</a>.</p>
<p>OK, thanks.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/button-customization#comment-318611</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Thu, 13 Mar 2014 17:51:28 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=184#comment-318611</guid>

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

@Chris - axes are not Java objects, so you cannot use &lt;i&gt;&lt;b&gt;findjobj&lt;/b&gt;&lt;/i&gt; with them. And no, they don&#039;t have tooltips.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/button-customization#comment-318603">Chris</a>.</p>
<p>@Chris &#8211; axes are not Java objects, so you cannot use <i><b>findjobj</b></i> with them. And no, they don&#8217;t have tooltips.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
