开发者

Is there a way to change the title of the MATLAB Command Window?

开发者 https://www.devze.com 2022-12-14 19:32 出处:网络
I\'m using the C++ API to fire up MATLAB (via engOpenSingleUse).Everything\'s working fine.But I\'d like to change the title of the window from \"MATLAB Command Window\" to something else.

I'm using the C++ API to fire up MATLAB (via engOpenSingleUse). Everything's working fine. But I'd like to change the title of the window from "MATLAB Command Window" to something else.

I often have 4 or 5 of them open, and occasionally one gets orphaned if my program crashes. If I could c开发者_JS百科hange the title, I'd have a better shot of knowing which one was which.

Is there a MATLAB command I could execute (via engEvalString) that would do this?


For Matlab 7:

jDesktop = com.mathworks.mde.desk.MLDesktop.getInstance;
jDesktop.getMainFrame.setTitle('my new title');

*or specifically for the Command Window:

cmdWin = jDesktop.getClient('Command Window');
cmdWin.getTopLevelAncestor.setTitle('my new title');

For Matlab 6:

jDesktop = com.mathworks.ide.desktop.MLDesktop.getMLDesktop;
jDesktop.getMainFrame.setTitle('my new title');

*or for the Command Window:

cmdWin = jDesktop.getClient('Command Window');
cmdWin.getTopLevelWindow.setTitle('my new title');


Other related undocumented desktop features are described here:
http://UndocumentedMatlab.com/blog/tag/desktop/


Try coding directly against the Java AWT classes. This may be more flexible and work inside the Matlab engine running under C++. (Haven't tested it in that context, since I don't use the engine.)

function change_win_title(oldName, newName)

wins = java.awt.Window.getOwnerlessWindows();
for i = 1:numel(wins)
    if isequal(char(wins(i).getTitle()), oldName)
        wins(i).setTitle(newName);
    end
end

You'd use it like this.

change_win_title('MATLAB Command Window', 'My new window name')

You can use other tests (window class, etc) to identify the windows of interest.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号