Why am I receiving error when using uifigure?
64 views (last 30 days)
Show older comments
Alena Schwartz
on 4 Oct 2021
Commented: Alena Schwartz
on 4 Oct 2021
I am trying to run a program which uses the uifigure command to create a GUI. My code was running fine yesterday. Today, when I try running the code, I get the following error message:
Error using uilistbox (line 42)
Functionality not supported with figures created with the figure function. For more information, see
Graphics Support in App Designer.
Error in slicingObjectsV01 (line 44)
h.listBox = uilistbox(h.loadPanel);
I cannot figure out how to fix this. I am using the uifigure command so I do not understand why MATLAB thinks that I am using the figure command.
Here is the beginning of my code:
%% GUI
h.slicingObjects = uifigure;
h.slicingObjects.Color = [0.8 0.8 1];
h.slicingObjects.Position = [45 70 1410 900];
h.slicingObjects.Units = 'Pixels';
h.slicingObjects.Resize = 'Off';
h.slicingObjects.Visible = 'off';
h.slicingObjects.Name = 'Slicing Objects';
%% Image Display Plot
h.sliceDisplayBackground = uiaxes(h.slicingObjects,'Units','Pixels');
h.sliceDisplayBackground.XTick = [];
h.sliceDisplayBackground.YTick = [];
h.sliceDisplayBackground.Color = [0 0 0];
h.sliceDisplayBackground.Position = [10 10 880 880];
h.sliceDisplay = uiaxes(h.slicingObjects,'units','pixels');
h.sliceDisplay.XTick = [];
h.sliceDisplay.YTick = [];
h.sliceDisplay.Color = 'black';
h.sliceDisplay.Position = [10 10 880 880];
%% Load Panel
h.loadPanel = uipanel('units','pixels');
h.loadPanel.Title = 'Load';
h.loadPanel.TitlePosition = 'centertop';
h.loadPanel.BackgroundColor = 'white';
h.loadPanel.FontName = 'Century Gothic';
h.loadPanel.FontSize = 20;
h.loadPanel.FontWeight = 'bold';
h.loadPanel.Position = [900 640 500 250];
listBoxItems = {'Series 1','Series 2','Series 3','Series 4'};
% List Box
h.listBox = uilistbox(h.loadPanel);
h.listBox.Items = listBoxItems;
h.listBox.BackgroundColor = 'white';
h.listBox.FontName = 'Century Gothic';
h.listBox.FontSize = 15;
h.listBox.Enable = 'off';
h.listBox.Position = [20 90 460 120];
0 Comments
Accepted Answer
Walter Roberson
on 4 Oct 2021
h.loadPanel = uipanel('units','pixels');
You did not parent that call, so uipanel() is going to look for the current figure using gcf -- which only looks for traditional figures, not for uifigure() . It would not find any current figure so it would create one to be the owner of the uipanel.
You need to pass in the parent of the uipanel to the uipanel() call.
More Answers (0)
See Also
Categories
Find more on Develop uifigure-Based 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!