classdef app2 < matlab.apps.AppBase

  % Properties that correspond to app components
  properties (Access = public)
    UIFigure            matlab.ui.Figure
    NameEditField       matlab.ui.control.EditField
    NameEditFieldLabel  matlab.ui.control.Label
    HelloworldLabel     matlab.ui.control.Label
  end

  % Callbacks that handle component events
  methods (Access = private)

    % Value changed function: NameEditField
    function NameEditFieldValueChanged(app, event)
      value = app.NameEditField.Value;
      app.HelloworldLabel.Text = "Mein Name ist " + value;
    end
  end

  % Component initialization
  methods (Access = private)

    % Create UIFigure and components
    function createComponents(app)

      % Create UIFigure and hide until all components are created
      app.UIFigure = uifigure('Visible', 'off');
      app.UIFigure.Position = [100 100 310 352];
      app.UIFigure.Name = 'MATLAB App';

      % Create HelloworldLabel
      app.HelloworldLabel = uilabel(app.UIFigure);
      app.HelloworldLabel.Position = [92 281 123 22];
      app.HelloworldLabel.Text = 'Hello, world';

      % Create NameEditFieldLabel
      app.NameEditFieldLabel = uilabel(app.UIFigure);
      app.NameEditFieldLabel.HorizontalAlignment = 'right';
      app.NameEditFieldLabel.Position = [72 206 40 22];
      app.NameEditFieldLabel.Text = 'Name:';

      % Create NameEditField
      app.NameEditField = uieditfield(app.UIFigure, 'text');
      app.NameEditField.ValueChangedFcn = createCallbackFcn(app, @NameEditFieldValueChanged, true);
      app.NameEditField.Position = [127 206 100 22];

      % Show the figure after all components are created
      app.UIFigure.Visible = 'on';
    end
  end

  % App creation and deletion
  methods (Access = public)

    % Construct app
    function app = app2

      % Create UIFigure and components
      createComponents(app)

      % Register the app with App Designer
      registerApp(app, app.UIFigure)

      if nargout == 0
        clear app
      end
    end

    % Code that executes before app deletion
    function delete(app)

      % Delete UIFigure when app is deleted
      delete(app.UIFigure)
    end
  end
end