MATLAB GUI - Set transparent background color for components

When I'm adding a MATLAB GUI component (e.g., text, button group, etc.), the default background is gray, which makes it look dissonant. How do I set them transparent?

回答 (3 件)

Matt Fig
Matt Fig 2011 年 5 月 21 日

1 投票

For example....
F = figure;
B = uicontrol('style','text','string','hello');
pause(.75) % Pause to see the change....
set(B,'backgroundcolor',get(F,'color'))

6 件のコメント

YIMING
YIMING 2011 年 5 月 21 日
Thanks for your reply. But what if I'm using GUIDE to create my GUI?
Matt Fig
Matt Fig 2011 年 5 月 21 日
Put in your OpeningFcn:
set(handles.pushbutton1,'backgroundc',get(handles.figure1,'color'))
Or similar.
YIMING
YIMING 2011 年 5 月 21 日
Thanks for your suggestion. But your approach only sets the component's background the same as that of the figure's. However what I want is something really "transparent". For example, if I have added a background image (texture) to the feature, your method doesn't work.
Matt Fig
Matt Fig 2011 年 5 月 21 日
To do that you will have to use Java, as Daniel suggest below. However, this is always a little dangerous because what works with Java in one release of MATLAB may not work with another, and may not work on different platforms. It is usually better to use a workaround like I show if you plan on sharing or possibly demonstrating your GUI on another machine...
Matt Fig
Matt Fig 2011 年 5 月 21 日
Actually, you can do similar with an image... look for example at GUI_40 here:
http://www.mathworks.com/matlabcentral/fileexchange/24861-41-complete-gui-examples
shalu vijay
shalu vijay 2019 年 2 月 25 日
The GUI_40 is working only for push buttons. It is not making other objects like text and check boxes transparent.

サインインしてコメントする。

Daniel Shub
Daniel Shub 2011 年 5 月 21 日

0 投票

You cannot easily have the uicontrols (i.e., gui components) be transparent. You can force it with java:
but probably not directly from guide wth mouse clicks.
You can set it to the figure background color like Matt suggests.
This can be done in guide by right clicking the object, selecting object properties, and then setting the background color property.
Robert Cumming
Robert Cumming 2014 年 12 月 12 日

0 投票

I know this is an old post - but if anyone comes across this you may be interested in this blog on undocumentedmatlab

カテゴリ

タグ

質問済み:

2011 年 5 月 21 日

コメント済み:

2019 年 2 月 25 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by