App Designer component generated by code not displaying

23 visualizaciones (últimos 30 días)
Bob
Bob el 9 de Dic. de 2025
Comentada: Matt J el 10 de Dic. de 2025
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

Respuesta aceptada

Matt J
Matt J el 9 de Dic. de 2025
Editada: Matt J el 9 de Dic. de 2025
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 comentarios
Bob
Bob el 10 de Dic. de 2025
Perfect! I very much appreciate your insights. Never would I have figured that out!
Bob
Matt J
Matt J el 10 de Dic. de 2025
You're welcome, but please Accept-click the answer to indicate that it resolved your question.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Develop uifigure-Based Apps en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2025b

Community Treasure Hunt

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

Start Hunting!

Translated by