Why the panel was not Visible??

I write this code inside callback function in guide pushbutton, to create programatical panel, but it was not visible. The code excute without any error.
% --- Executes on button press in bright.
function bright_Callback(hObject, eventdata, handles)
% hObject handle to bright (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%create new Panel for Brightness, Contrast, Resolution.
global stat
stat = 0;
figure1 = findobj('Tag','figure1');
brightPanel = uipanel('Parent',figure1,'Title','Sitting',...
'Position',[83, 118, 250, 400],...
'Tag','BrightPanel');
set(brightPanel,'Visible','off');
brightText = uicontrol(brightPanel,'Style','text',...
'String','Brightness',...
'Position',[50, 327, 82, 25]);
brightValueEdit = uicontrol(brightPanel,'Style','edit',...
'String','',...
'Tag','BVEdit',...
'Position',[143, 327, 40, 25]);
brightValueSlider = uicontrol(brightPanel,'Style','slider',...
'String','',...
'Tag','BVSlider',...
'Max',100,'Min',-100,'Value',0,...
'SliderStep',[1 5],...
'Position',[55, 283, 140, 18]);
set(brightPanel,'Visible','on');
set(handles.back2mainMenu,'Visible','on');
set(handles.mainMenu,'Visible','off');
PS: the mainMenu was hide and back2mainMenu puchbutton was shwo.

Answers (2)

Walter Roberson
Walter Roberson on 22 Dec 2016
One possibility is that the panel might be behind another panel or axes. Starting in R2014b, uicontrols and uipanel no longer automatically appear on top when they are visible; if something else covers them up then they will not be visible.

6 Comments

Thank you, but how to bring it to the front
It still not work. I add this line
uistack(brightPanel, 'top');
set(brightPanel,'Visible','on');
Please attach your code and your .fig
Here is the project file. The callback is (bright_Callback). Thank you for your help.
But how to set the order?

Sign in to comment.

Image Analyst
Image Analyst on 23 Dec 2016
You're using GUIDE so why not just place the panels in GUIDE? Why go to all the tedious trouble to create panels from scratch? For example if your figure units were 'normalized' and your panel units are in 'pixels' then your panels might be off the screen. Make it easy for yourself and just put the panels on there with GUIDE. I mean you're already using GUIDE so why not?

3 Comments

I have to hide mainMenu panel and show brightPanel at same position, how I can do this with GUIDE
You can do it. Just put all the panels up the, put your controls into them. then arrange your panels, overlapping them if wanted. Then just set visibility in your code. But you don't need to recreate them in code, just set their visibility.
Ok. That is a good idea. Thank you for help.

Sign in to comment.

Tags

Asked:

on 22 Dec 2016

Commented:

on 6 Jun 2023

Community Treasure Hunt

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

Start Hunting!