how to get the handle of all static texts present in a uipanel to change their backgroung color?
5 views (last 30 days)
Show older comments
Harish Babu Kankanala
on 7 Jun 2016
Edited: Harish Babu Kankanala
on 13 Jun 2016
I know how to Change the backgound color of a Static Text.
set(handles.text1,'BackgroundColor','w');
set(handles.text2,'BackgroundColor','w');
But I want to Change the Background of all the Static Texts present in the uipanel. So, how can i get the handle of all the Static Texts and Change their backgound Color at once?
0 Comments
Accepted Answer
Geoff Hayes
on 12 Jun 2016
Harish - you can use the findobj function to get all the handles that match a certain criteria and then change the background colour for each. For example, suppose that you have a pushbutton callback that colours the background red for each of the static texts in your panel. We use findobj as
function pushbutton1_Callback(hObject, eventdata, handles)
hStaticTexts = findobj('Parent',handles.uipanel1, 'Style','text');
if ~isempty(hStaticTexts)
set(hStaticTexts,'BackgroundColor','r');
end
hStaticTexts is an array of handles to the graphics objects whose parent is handles.uipanel1 and whose style is text.
Try the above and see what happens!
1 Comment
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!