|
Dear Albert!
> I found that 1 second was to short. Four worked fine, so i used 5 seconds for a safty margin. Here is the code I used at the bottom of my startup function:
>
> % check for previously created startup_timer
> T_existing = timerfindall('Name','startup_timer');
> if ~isempty(T_existing)
> stop(T_existing);
> delete(T_existing);
> end
> clear T_existing;
> % create timer to change the window title
> windowtitle = ['MATLAB ',version,', MyEnvir ',My_version];
> com.mathworks.mde.desk.MLDesktop.getInstance.getMainFrame.setTitle(windowtitle);
> T = timer('UserData',windowtitle);
> set(T,'Name','startup_timer'); % name so we can find it later
> set(T,'TimerFcn',@setMainFrameTitle); % set timer function
> set(T,'BusyMode','queue');
> set(T,'StartDelay',5); % run 5 seconds after start
> set(T,'ObjectVisibility','off'); % hide from timerfind
> start(T); % start the timer
>
> function setMainFrameTitle(t,event) %#ok<INUSD>
> windowtitle = t.UserData;
> com.mathworks.mde.desk.MLDesktop.getInstance.getMainFrame.setTitle(windowtitle);
I added a check, if Matlab was started with the JVM, before calling COM:
if usejava('desktop')
create timer...
end
And I delete the TIMER object after the single shot:
function setMainFrameTitle(t,event) %#ok<INUSD>
windowtitle = t.UserData;
com.mathworks.mde.desk.MLDesktop.getInstance.getMainFrame.setTitle(windowtitle);
stop(t);
delete(t);
You are right: 1 sec was too short. 2 sec worked for me for some time, but know I need 4 sec also. --- What the hell does happen in the background 3 sec after startup has finished?!
Kind regards, Jan
|