
App Designer component generated by code not displaying
28 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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 个评论
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 Center 和 File Exchange 中查找有关 Develop uifigure-Based Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

