如何在启动时最大化MATLAB GUI图形/窗口?

时间:2014-06-11 14:44:09

标签: matlab startup figure

我目前正在评估MATLAB中的GUI,并想知道如何在启动时最大化GUI窗口,而无需用户交互。我正在使用的功能在下文中说明,如果在按下按钮时调用它可以正常工作,但在图中的OpeningFcn中调用它将无济于事。

http://www.mathworks.com/matlabcentral/fileexchange/25471-maximize

在某个启动部分放置函数调用的任何帮助,这是在绘制GUI窗口后执行的?我在MATLAB GUI中搜索了与启动代码相关的解决方案,但迄今为止没有结果。 在此先感谢您的努力。

1 个答案:

答案 0 :(得分:2)

由于许多人似乎对此感兴趣并且仍然没有公开解决方案,我将描述我的方法:

  1. % Initialize a timer, which executes its callback once after one second timer1 = timer('Period', 1, 'TasksToExecute', 1, ... 'ExecutionMode', 'fixedRate', ... 'StartDelay', 1); % Set the callback function and declare GUI handle as parameter timer1.TimerFcn = {@timer1_Callback, findobj('name', 'YourGUIName')}; timer1.StopFcn = @timer1_StopFcn; start(timer1); 函数中,添加以下行:

    timer1_Callback
  2. 声明timer1_StopFcn%% timer1_Callback % --- Executes after each timer event of timer1. function timer1_Callback(obj, eventdata, handle) % Maximize the GUI window maximize(handle); %% timer1_StopFcn % --- Executes after timer stop event of timer1. function timer1_StopFcn(obj, eventdata) % Delete the timer object delete(obj); 函数:

    maximize
  3. 声明function maximize(hFig) %MAXIMIZE: function which maximizes the figure withe the input handle % Through integrated Java functionality, the input figure gets maximized % depending on the current screen size. if nargin < 1 hFig = gcf; % default: current figure end drawnow % required to avoid Java errors jFig = get(handle(hFig), 'JavaFrame'); jFig.setMaximized(true); end 函数:

    maximize
  4. AND ACTFINISH BETWEEN '01-JUN-2015' AND '30-JUN-2015' 函数的来源:

    http://www.mathworks.com/matlabcentral/fileexchange/25471-maximize

相关问题