Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

setting background of edit text to 'transparent'

1,518 views
Skip to first unread message

praveen

unread,
Dec 14, 2009, 3:38:01 AM12/14/09
to
hello everyone,

i'm creating a gui (using guide) which has a background image.i want the 'static text' box to display only the string ,ie. the background of static text must be transparent.how can it be done?we can't achieve this using the 'property inspector' .

praveen

praveen

unread,
Dec 14, 2009, 3:53:04 AM12/14/09
to
also tell me how to make background of 'static text' transparent

Jan Simon

unread,
Dec 14, 2009, 1:26:01 PM12/14/09
to
Dear praveen!

> also tell me how to make background of 'static text' transparent

Just do not use a UICONTROL('Style', 'text'), but a TEXT object.
I don't know how to do this in GUIDE, because I program my GUIs manually.

Good luck, Jan

Sermed

unread,
Dec 16, 2009, 1:07:04 PM12/16/09
to
Hi Jan
I had the same problem and decided to start over and build my GUI manually;

What do you mean by using TEXT object?

T.static_text = text('string', '.....' , 'position', [.....]) in stead of
T.static_text = uicontrol('style', 'text','string', '.....' , 'position', [.....])

Best regards
Sermed

"Jan Simon" <matlab.T...@nMINUSsimon.de> wrote in message <hg5vvp$6op$1...@fred.mathworks.com>...

Jan Simon

unread,
Dec 16, 2009, 5:38:04 PM12/16/09
to
Dear Sermed!

> What do you mean by using TEXT object?
>
> T.static_text = text('string', '.....' , 'position', [.....]) in stead of
> T.static_text = uicontrol('style', 'text','string', '.....' , 'position', [.....])

Yes.
The object created by the TEXT command has a transparent background as default. The TEXT is needs and axes, which can be inserted in GUIDE, but as far as I can see, you have to create the TEXT manually (not through buttons in GUIDE).

Meta-reply: The second time I can answer with "yes" or "no" today. See:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/268531#702749
Thanks, this made my day.

Jan

Sermed

unread,
Dec 16, 2009, 6:45:22 PM12/16/09
to
Dear Jan

I've tried to use the TEXT object as shown below:
H.txt_obj = text('string', 'static text test', 'position', [30, 150, 100, 100])

and I got:
??? Error using ==> text
Value must be a 2 or 3 element vector

I have designed the GUI using GUIDE in the begging, but because the transparency static text is important for my work, I've started again designing the same GUI manually.

My question is:
Is it possible to make the static text background invisible and how?

Thanx for you efforts


"Jan Simon" <matlab.T...@nMINUSsimon.de> wrote in message <hgbngc$mo0$1...@fred.mathworks.com>...

Nathan

unread,
Dec 16, 2009, 6:52:18 PM12/16/09
to
On Dec 16, 3:45 pm, "Sermed " <sermad...@hotmail.com> wrote:
> Dear Jan
>
> I've tried to use the TEXT object as shown below:
> H.txt_obj  = text('string', 'static text test', 'position', [30, 150, 100, 100])
>
> and I got:
> ??? Error using ==> text
> Value must be a 2 or 3 element vector
>
> I have designed the GUI using GUIDE in the begging, but because the transparency static text is important for my work, I've started again designing the same GUI manually.
>
> My question is:
> Is it possible to make the static text background invisible and how?
>
> Thanx for you efforts
>


If you read the documentation for TEXT, you would see that you called
it wrong.

h = text(x,y,'string')

so, in your case:

H.txt_obj = text(30,150,'static text test')
axis off %*

Note: text is not the same as a static text object

* as Jan mentioned, TEXT places a text object on axes.

-Nathan

Sermed

unread,
Dec 18, 2009, 11:08:02 AM12/18/09
to
Dear Nathan

I've used the text instead of uicontrol:

text(0.5, 0.5, 'STRING', 'HorizontalAlignment','center','BackgroundColor', 'none');

The color of text background was gray??

What have I done wrong??

Thanks in advance
Sermed

Nathan <ngre...@gmail.com> wrote in message <6b08e8b2-c336-430f...@z35g2000prh.googlegroups.com>...

Nathan

unread,
Dec 18, 2009, 1:15:40 PM12/18/09
to
On Dec 18, 8:08 am, "Sermed " <sermad...@hotmail.com> wrote:
> Dear Nathan
>
> I've used the text instead of uicontrol:  
>
> text(0.5, 0.5, 'STRING', 'HorizontalAlignment','center','BackgroundColor', 'none');
>
> The color of text background was gray??
>
> What have I done wrong??
>
> Thanks in advance
> Sermed
>
> Nathan <ngrec...@gmail.com> wrote in message <6b08e8b2-c336-430f-8eda-410625340...@z35g2000prh.googlegroups.com>...

> > On Dec 16, 3:45 pm, "Sermed " <sermad...@hotmail.com> wrote:
> > > Dear Jan
>
> > > I've tried to use the TEXT object as shown below:
> > > H.txt_obj  = text('string', 'static text test', 'position', [30, 150, 100, 100])
>
> > > and I got:
> > > ??? Error using ==> text
> > > Value must be a 2 or 3 element vector
>
> > > I have designed the GUI using GUIDE in the begging, but because the transparency static text is important for my work, I've started again designing the same GUI manually.
>
> > > My question is:
> > > Is it possible to make the static text background invisible and how?
>
> > > Thanx for you efforts
>
> > If you read the documentation for TEXT, you would see that you called
> > it wrong.
>
> > h = text(x,y,'string')
>
> > so, in your case:
>
> > H.txt_obj = text(30,150,'static text test')
> > axis off %*
>
> > Note: text is not the same as a static text object
>
> > * as Jan mentioned, TEXT places a text object on axes.
>
> > -Nathan
>
>

What makes you think the background of the object is gray?

Try this:

text(0.5, 0.5, 'STRING',
'HorizontalAlignment','center','BackgroundColor', 'none');

axis off %is this the gray you were talking about?

set(gcf,'Color','b')
%the text background (as well as the figure) should be blue.
set(gcf,'Color','w')
%text and figure background should be white

If that's not what you mean by transparent, I'm confused.

-Nathan

Shabnam Shaikh

unread,
Apr 14, 2010, 3:34:03 AM4/14/10
to

hi der...
i was too facing d prob;em of making d backgroud of static text as transparent or incisible....but d use of the below code has helped me...

h = text(x,y,'string')

well friends....write d above code in
function st_OpeningFcn(hObject, eventdata, handles, varargin)
....
....

here st is d name of my figure...

anyways thankyou very much sir....D code has really helped me.....
have a great day!!!

0 new messages