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:
Symbols in uicontrol textbox

Subject: Symbols in uicontrol textbox

From: Hans

Date: 21 Jan, 2010 15:28:02

Message: 1 of 7

Hi Everybody
As I understand uicontrol cannot show symbols. In my example I have a GUI with a list box where different options can be choosed. The options are then shown in a textbox when I press the pushbutton. Can somebody come up with an example how to solve my problem soo symbols can be shown in the textbox?I would really appreciate if somebody could show me an example? I have been told that I could use java programming, but I do not have experience with Java programming. Hope the example under can shown what I want.

function test6()


% global vectorOfValues
% vectorOfValues = [];

f=figure('name','test',...
    'numbertitle','off',...
    'menubar','none',...
    'color',[0.85, 0.85, 0.85],...
    'units','normalized',...
    'position',[0 0.1 0.95 0.87]);

col=get(f,'color');

uicontrol('style','pushbutton',...
    'units','normalized',...
    'position',[0.325 0.1 0.10 0.04],...
    'string','Table',...
    'backgroundcolor',col,...
    'callback',@go99709);
 
 


ht2=uicontrol('style','text',...
    'units','normalized',...
    'position',[0.5, 0.3,0.4 0.5],...
    'backgroundcolor',[0.95, 0.95, 0.95],...
    'string','',...
    'fontsize',15);

 hlb576=uicontrol('style','listbox',...
    'units','normalized',...
    'position',[0.3 0.3 0.15 0.1],...
    'string',{'y11';'y22'});
    
    function go99709(varargin)

    choice=get(hlb576,'value');
    if choice==1
    y6=[10 20 30 40]
    y66=[1 2 3 4]
    set(ht2,'string',sprintf('%.0f \\circ %.0f min\n',[y6';y66']))
    elseif choice==2
    set(ht2,'string','Car price')
    end
    end
end

Best Regards

Hans

Subject: Symbols in uicontrol textbox

From: Matt Fig

Date: 21 Jan, 2010 15:52:05

Message: 2 of 7

You can insert symbols using HTML strings.

Subject: Symbols in uicontrol textbox

From: Hans

Date: 21 Jan, 2010 17:17:22

Message: 3 of 7

"Matt Fig" <spamanon@yahoo.com> wrote in message <hj9t75$9an$1@fred.mathworks.com>...
> You can insert symbols using HTML strings.

Dear Matt

As I know HTML does not support uicontrol textbox?

Can you shown an example?

I know it support listboxes. As you can see from my code, I want to use sprintf to pass a string to a string in a uicontrol textbox.

Best Regards

Hans

Subject: Symbols in uicontrol textbox

From: Yair Altman

Date: 21 Jan, 2010 19:19:04

Message: 4 of 7

> As I know HTML does not support uicontrol textbox?
>
> Can you shown an example?
>
> I know it support listboxes. As you can see from my code, I want to use sprintf to pass a string to a string in a uicontrol textbox.


I posted an article yesterday about how to insert HTML and other rich contents (images, controls etc.) into a Matlab editbox - http://undocumentedmatlab.com/blog/rich-matlab-editbox-contents/
Use this new post together with the links I posted as reply to your earlier post a few days ago.

Don't be lazy - nobody has time to code your entire program for you. The links I provided should be enough to solve your problem after minor tweaking.

Yair Altman
http://UndocumentedMatlab.com

Subject: Symbols in uicontrol textbox

From: Hans

Date: 23 Jan, 2010 12:14:02

Message: 5 of 7

"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message <hja9b8$jv2$1@fred.mathworks.com>...
> > As I know HTML does not support uicontrol textbox?
> >
> > Can you shown an example?
> >
> > I know it support listboxes. As you can see from my code, I want to use sprintf to pass a string to a string in a uicontrol textbox.
>
>
> I posted an article yesterday about how to insert HTML and other rich contents (images, controls etc.) into a Matlab editbox - http://undocumentedmatlab.com/blog/rich-matlab-editbox-contents/
> Use this new post together with the links I posted as reply to your earlier post a few days ago.
>
> Don't be lazy - nobody has time to code your entire program for you. The links I provided should be enough to solve your problem after minor tweaking.
>
> Yair Altman
> http://UndocumentedMatlab.com

Dear Yair

Thank you very much for taking time to reply my message. I tried to use the:

labelStr = '<html> <f>Price</b> <html><f>Temperature</b> [C<html>º]';
jLabel = javaObjectEDT('javax.swing.JLabel',labelStr);
[hcomponent,hcontainer] = javacomponent(jLabel,[700, 730,380 30],gcf);
        
It worked fine I just have some questions:
How do I reset a jLabel or delete a jLabel?
How do I change the background color of the jLabel?
I need it for my GUI

Best Regards

Hans
        

Subject: Symbols in uicontrol textbox

From: Yair Altman

Date: 23 Jan, 2010 17:55:04

Message: 6 of 7

> labelStr = '<html> <f>Price</b> <html><f>Temperature</b> [C<html>º]';
> jLabel = javaObjectEDT('javax.swing.JLabel',labelStr);
> [hcomponent,hcontainer] = javacomponent(jLabel,[700, 730,380 30],gcf);
>
> It worked fine I just have some questions:

Your labelStr uses invalid HTML syntax. I assume that you meant this:
labelStr = '<html> <b>Price</b> <b>Temperature</b> [C°]';

> How do I reset a jLabel or delete a jLabel?

delete(hcomponent);

> How do I change the background color of the jLabel?

set(hcomponent,'Background',java.awt.Color(1,.5,.3)); % RGB values between 0.0-1.0

Yair Altman
http://UndocumentedMatlab.com

Subject: Symbols in uicontrol textbox

From: Hans

Date: 25 Jan, 2010 09:41:03

Message: 7 of 7

"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message <hjfd5o$t1m$1@fred.mathworks.com>...
> > labelStr = '<html> <f>Price</b> <html><f>Temperature</b> [C<html>º]';
> > jLabel = javaObjectEDT('javax.swing.JLabel',labelStr);
> > [hcomponent,hcontainer] = javacomponent(jLabel,[700, 730,380 30],gcf);
> >
> > It worked fine I just have some questions:
>
> Your labelStr uses invalid HTML syntax. I assume that you meant this:
> labelStr = '<html> <b>Price</b> <b>Temperature</b> [C°]';
>
> > How do I reset a jLabel or delete a jLabel?
>
> delete(hcomponent);
>
> > How do I change the background color of the jLabel?
>
> set(hcomponent,'Background',java.awt.Color(1,.5,.3)); % RGB values between 0.0-1.0
>
> Yair Altman
> http://UndocumentedMatlab.com

Thank you very much Yair Altman

It all works fine now. It just have one question regarding the postion of the Jabel label. In my GUI I use 'units','normalized' in the uicontrols for postioning the different components. Can the Jlabel accept 'units','normalized'?

Best Regards

Hans

Tags for this Thread

No tags are associated with 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