Why am I receiving error when using uifigure?

조회 수: 64 (최근 30일)
Alena Schwartz
Alena Schwartz 2021년 10월 4일
댓글: Alena Schwartz 2021년 10월 4일
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];

채택된 답변

Walter Roberson
Walter Roberson 2021년 10월 4일
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.
  댓글 수: 1
Alena Schwartz
Alena Schwartz 2021년 10월 4일
Awesome! Thanks! I got it to launch the GUI!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by