声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 3651|回复: 5

[共享资源] 【转贴】更改Figure图标的新方法

[复制链接]
发表于 2009-11-18 21:06 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
在这里http://forum.simwe.com/viewthread.php?tid=880867&page=1#pid1824705
看到这个, 觉得好玩, 转来与大家共同欣赏!

  1. function chgicon(hfig,iconfile)
  2. %CHGICON changes the Figure HFIG's icon to the icon specified by ICONFILE
  3. % HFIG must be a figure handle.
  4. % ICONFILE is a string specifies the path to an imagefile.
  5. %
  6. %WARNING:
  7. % Changing the matlab icon violate the mathworks license. THis function can
  8. % only be used for study purpose. Please delete it within 24 hours.
  9. %
  10. % Author: junziyang (simwer@126.com)
  11. % Ver.1.0
  12. % 2009-05-20
  13. error(nargchk(2,2,nargin));
  14. if ~ishandle(hfig) && ~isequal(get(hfig,'Type'),'figure')
  15. error('The first input argument must be a Figure handle.');
  16. end
  17. if ~ischar(iconfile) || ~exist(iconfile,'file')
  18. error('Icon file name is not input properly.');
  19. end
  20. mde = com.mathworks.mde.desk.MLDesktop.getInstance;
  21. if isequal(get(hfig,'NumberTitle'),'off') && isempty(get(hfig,'Name'))
  22. figTag = 'junziyang'; %Name the figure temporarily
  23. set(hfig,'Name',figTag);
  24. elseif isequal(get(hfig,'NumberTitle'),'on') && isempty(get(hfig,'Name'))
  25. figTag = ['Figure ',num2str(hfig)];
  26. elseif isequal(get(hfig,'NumberTitle'),'off') && ~isempty(get(hfig,'Name'))
  27. figTag = get(hfig,'Name');
  28. else
  29. figTag = ['Figure ',num2str(hfig),': ',get(hfig,'Name')];
  30. end
  31. drawnow %Update figure window
  32. jfig = mde.getClient(figTag); %Get the underlying JAVA object of the figure.
  33. jfig.setClientIcon(javax.swing.ImageIcon(iconfile));
  34. if isequal(get(hfig,'Name'),'junziyang')
  35. set(hfig,'Name',''); %Delete the temporary figure name
  36. end
复制代码


月初即想转贴, 并询问友网是否允许转贴!
已经版主同意, 但想若经楼主同意好像更尊重些, 一等一忙竟给忘记了!
刚在中文又看到http://www_ilovematlab_cn/viewthread.php?tid=57132&page=1#pid532336 (change "_" to ".")
不知是否为原创者, 但肯定是旧版!
怕再次忘记, 先贴了

[ 本帖最后由 ChaChing 于 2010-5-21 18:18 编辑 ]

评分

1

查看全部评分

回复
分享到:

使用道具 举报

发表于 2012-2-9 16:18 | 显示全部楼层
感谢楼主!
发表于 2012-3-24 00:46 | 显示全部楼层
谢谢 楼主啊
发表于 2012-9-25 12:14 | 显示全部楼层
学习啦
发表于 2012-10-22 19:18 | 显示全部楼层
这都可以啊
发表于 2013-8-31 14:13 | 显示全部楼层
这是什么,怎么我运行不出来??
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-18 12:07 , Processed in 0.081351 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表