Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Multiple line push button string

Subject: Multiple line push button string

From: Stephen

Date: 22 Jul, 2010 13:03:04

Message: 1 of 6

How do I get a multiple line push button string? In the create function I tried,

str = sprintf('Overplot\nSelected\Variables');
set(hObject,'String',str);

This resulted in only "Overplot" appearing on the push button.

Cheers,
SteveB.

Subject: Multiple line push button string

From: Andy

Date: 22 Jul, 2010 13:23:04

Message: 2 of 6

"Stephen " <stephen.bachner@navy.mil> wrote in message <i29fi8$dc3$1@fred.mathworks.com>...
> How do I get a multiple line push button string? In the create function I tried,
>
> str = sprintf('Overplot\nSelected\Variables');
> set(hObject,'String',str);
>
> This resulted in only "Overplot" appearing on the push button.
>
> Cheers,
> SteveB.

I don't know that it's possible with just the MATLAB uicontrol. But you can do it with Java. Download findjobj from the FEX, and look at the function createJButton. (This is the function used to create the buttons along the bottom of the GUI, which are multi-line buttons. These buttons are created around line 1300.)

Subject: Multiple line push button string

From: Jan Simon

Date: 22 Jul, 2010 15:47:07

Message: 3 of 6

Dear Stephen,

see also createButtonLabel of Brett Shoelson:
  http://www.mathworks.com/matlabcentral/fileexchange/15018
and uibutton of Doug Schwarz:
  http://www.mathworks.com/matlabcentral/fileexchange/10743

Modern Matlab versions can interprete HTML in buttons also, but this is not documented:
  uicontrol('style', 'pushbutton', 'position', [10, 10, 200, 200], ...
    'String', '<html>Line 1<br>Line2');

Good luck, Jan

Subject: Multiple line push button string

From: Stephen

Date: 22 Jul, 2010 16:38:04

Message: 4 of 6

Thanks to both of you!

Cheers,
SteveB.

"Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote in message <i29p5r$5k5$1@fred.mathworks.com>...
> Dear Stephen,
>
> see also createButtonLabel of Brett Shoelson:
> http://www.mathworks.com/matlabcentral/fileexchange/15018
> and uibutton of Doug Schwarz:
> http://www.mathworks.com/matlabcentral/fileexchange/10743
>
> Modern Matlab versions can interprete HTML in buttons also, but this is not documented:
> uicontrol('style', 'pushbutton', 'position', [10, 10, 200, 200], ...
> 'String', '<html>Line 1<br>Line2');
>
> Good luck, Jan

Subject: Multiple line push button string

From: Jan Simon

Date: 22 Jul, 2010 17:02:39

Message: 5 of 6

Dear Stephen,

> Thanks to both of you!

And thanks to Yair in addition for the <html> trick.

Jan

Subject: Multiple line push button string

From: Yair Altman

Date: 22 Jul, 2010 18:56:06

Message: 6 of 6

"Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote in message <i29tjf$l8p$1@fred.mathworks.com>...
> Dear Stephen,
>
> > Thanks to both of you!
>
> And thanks to Yair in addition for the <html> trick.
>
> Jan

See more information about the HTML support here:
http://UndocumentedMatlab.com/blog/html-support-in-matlab-uicomponents/

Yair Altman
http://UndocumentedMatlab.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us