The alternative would be to use static text on the pushbutton.
No, but in the callback where you set the String property of the button you
can use TEXTWRAP:
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/textwrap.html
--
Steve Lord
sl...@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
I tried using textwrap as follows:
% Intialize a figure
hf = figure('Name','GUI');
% Define a uicontrol button
Btn_temp = uicontrol(...
'Parent',hf,...
'Units','normalized',...
'Position',[0.7,.15,.2,.1],...
'Style','pushbutton');
% Define a string for button
string = {'ABC DEF',...
'GHI JKL'};
% wrap string for uicontrol button
[outstring,newpos] = textwrap(Btn_temp,string);
% apply the string to the uicontrol button
set(Btn_temp,'String',outstring,'Position',newpos);
%The button string does not get the second line i.e. GHI JKL
"For uicontrol objects that display only one line
of text (check box, push button, radio button, toggle button),
if the string value is specified as a cell array of strings or padded string
matrix, only the first string of a cell array or of a padded string matrix
is displayed; the rest are ignored. Vertical slash ('|') characters are not
interpreted as line breaks and instead show up in the text displayed in the
uicontrol."
You might be able to do something with the underlying JAVA. Putting a textbox over the top of the pushbutton introduces problems as well, because clicking on the string will not trigger the pushbutton's callback.
We will bring the JAVA man to this thread:
Calling Yair Altman!
Indeed, I would be interested in a Java way to do this, but in the
meantime my uibutton is available:
--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.
Thanks Doug! That works perfect for now. Here is the updated code (after downloading uibutton), if someone is interested:
% Intialize a figure
hf = figure('Name','GUI');
% Define a string for button
string = {'ABC DEF',...
'GHI JKL'};
% Define a uicontrol button
Btn_temp = uibutton(...
'Parent',hf,...
'Units','normalized',...
'Position',[0.7,.15,.2,.1],...
'Style','pushbutton',...
'String',string);
--Naresh
Simply use HTML formatting:
set(Btn_temp, 'String', '<html>ABC DEF<br>GHI JKL');
More information:
http://undocumentedmatlab.com/blog/html-support-in-matlab-uicomponents/
Yair Altman
http://UndocumentedMatlab.com