Placing UIPanel on Figure in OpeningFcn

2 views (last 30 days)
Hello, I am trying to create an uipanel on a figure during the OpeningFcn using the following line:
bp = uipanel('Units','pixels','Position','[8 41 490 500],'Tag','BackgroundPanel','BorderType','none');
The Panel is created but it's placed on the calling figure. I tried several Parent settings but so far haven't come up with something working so the Panel is on the opening figure.
Can anybody help me with this please?
Best regards, Michael
  1 Comment
Adam
Adam on 2 Jun 2017
Edited: Adam on 2 Jun 2017
It would be more useful to show a version with the parent that you tried that didn't work. The above attempt certainly doesn't specify a parent and will end up in the wrong place if you open this figure from another figure.
Trying the obvious parent, as in Jan's answer works fine for me in a figure that is not launched from another, but should equally work fine however it is launched.

Sign in to comment.

Accepted Answer

Jan
Jan on 2 Jun 2017
Inside the OpeningFcn:
bp = uipanel('Units','pixels','Position','[8 41 490 500], ...
'Tag','BackgroundPanel','BorderType','none', ...
'Parent', hObject);
This seems to be the most obvious parent. What did you try?
  1 Comment
Michael Critchfield
Michael Critchfield on 2 Jun 2017
Thanks for that Jan Simon! I don't know what I have typed before as I thought I had tried this but it works fine now!!

Sign in to comment.

More Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!