App Designer component generated by code not displaying

조회 수: 28 (최근 30일)
Bob
Bob 2025년 12월 9일 1:37
댓글: Matt J 2025년 12월 10일 2:12
As a simple example, the expected label from the code below does not display. This is my first attempt to generate a component by code. Also first question to the forum. What am I missing?
methods (Access = private)
function startupFcn(app)
% Display a label as a simple example
lbl = uilabel(app.UIFigure);
lbl.Text = 'Hello, this is a label!';
lbl.Position = [100 300 200 30]; % [x y width height]
lbl.FontSize = 14;
lbl.FontColor = [0 0 1]; % Blue text
lbl = uilabel(app.Panel);
lbl.Text = 'Label inside a panel';
lbl.Position = [20 50 150 22];
end
end

채택된 답변

Matt J
Matt J 2025년 12월 9일 13:20
편집: Matt J 2025년 12월 9일 15:32
It is conspicuous to me that you are complaining about missing labels, but not about the missing uipanel!. Did you pre-populate the canvas with one? Assuming you did (and that it is named 'Panel') then there's nothing wrong with the code you have shown. Here is what your code gives me.
  댓글 수: 8
Bob
Bob 2025년 12월 10일 1:58
Perfect! I very much appreciate your insights. Never would I have figured that out!
Bob
Matt J
Matt J 2025년 12월 10일 2:12
You're welcome, but please Accept-click the answer to indicate that it resolved your question.

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2025b

Community Treasure Hunt

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

Start Hunting!

Translated by