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
|
|
0
|
|
|
|
Reply
|
Hans
|
1/21/2010 3:28:02 PM |
|
You can insert symbols using HTML strings.
|
|
0
|
|
|
|
Reply
|
Matt
|
1/21/2010 3:52:05 PM
|
|
"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
|
|
0
|
|
|
|
Reply
|
Hans
|
1/21/2010 5:17:22 PM
|
|
> 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
|
|
0
|
|
|
|
Reply
|
Yair
|
1/21/2010 7:19:04 PM
|
|
"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
|
|
0
|
|
|
|
Reply
|
Hans
|
1/23/2010 12:14:02 PM
|
|
> 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
|
|
0
|
|
|
|
Reply
|
Yair
|
1/23/2010 5:55:04 PM
|
|
"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
|
|
0
|
|
|
|
Reply
|
Hans
|
1/25/2010 9:41:03 AM
|
|
|
6 Replies
359 Views
(page loaded in 0.296 seconds)
|