Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: What's new in release 2010a?
Date: Tue, 16 Mar 2010 21:30:32 +0000 (UTC)
Organization: TACT Computer Systems Ltd
Lines: 19
Message-ID: <hnot9n$34o$1@fred.mathworks.com>
References: <hm5f0s$53r$1@fred.mathworks.com> <hmih5e$593$1@fred.mathworks.com> <hmjcto$bdv$1@canopus.cc.umanitoba.ca> <hmlapl$6e4$1@fred.mathworks.com> <1267717921.116676@irys.nyx.net> <hmqkhk$92j$1@fred.mathworks.com> <hmqm1a$cnv$1@fred.mathworks.com> <hn9co5$gcs$1@fred.mathworks.com> <hnor5d$smu$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1268775032 3224 172.30.248.35 (16 Mar 2010 21:30:32 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 16 Mar 2010 21:30:32 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 642467
Xref: news.mathworks.com comp.soft-sys.matlab:617403

> Still can't get multiple lines of text on a static guide text object.  I tried using a cell array of strings (actually using the java example in cell help & using the more difficult cellstr function) in the static text create function but it doesn't work.


Multi-line text labels are unsupported in the standard uicontrols, but you can use simple Java controls and HTML line-breaks for this:

jLabel = javax.swing.JLabel('<html>This is a long<br>multi-line string');
[jhLabel,hcontainer] = javacomponent(jLabel,[10,10,100,30],gcf);

If your multiple lines are stored in a cell-array, you can convert this into a multi-line HTML string as follows:

strs = {'very long','multi-line','string'};
htmlStr = sprintf('<html>%s%s', sprintf('%s<br>',c{1:end-1}), c{end});
jLabel = javax.swing.JLabel(htmlStr);
[hcomponent,hcontainer] = javacomponent(jLabel,[10,50,50,20],gcf);

More about using HTML in Matlab labels: http://undocumentedmatlab.com/blog/customizing-matlab-labels/

Yair Altman
http://UndocumentedMatlab.com