MATLAB ResizeFcn callback fails
1 回表示 (過去 30 日間)
古いコメントを表示
I am editing a GUI written in MATLAB and have a line in the OpeningFcn that sets the callback for resizeing the figure.
set(hObject, 'UserData', handles.ParentFig, 'ResizeFcn',@cbFigResize, 'CloseRequestFcn', @Cancel);
The callback is pasted below with much edited out for simplicity.
function cbFigResize(src,evt)
% check if figure width is less than 600
if fpos(3) < 600
%set min. width to 600
fpos(3) = 600
end
%check if figure height is less than 560
if fpos(4) <560
% set minimum height to 560
fpos(4) = 560;
end
My coworker runs Windows XP and an earlier version of MATLAB. I run Windows 7 and MATLAB 7.12.0.635. Now when he resizes figures they always resize properly. When I run the same code I can sometimes get the figure smaller than the above set minimum width and height limits. My coworker says it is a Windows 7 interrupt problem. If anybody else out there has this problem he found a simple but illogical workaround which I will post below.
function cbFigResize(src,evt,doStop)
if nargin < 3
doStop = false;
end
% check if figure width is less than 600
if fpos(3) < 600
%set min. width to 600
fpos(3) = 600
end
%check if figure height is less than 560
if fpos(4) <560
% set minimum height to 560
fpos(4) = 560;
end
if ~doStop
cbFigResize(src,evt,true)
end
You can see that this function calls itself with a flag that stops if from becoming an infinite loop. And now I cannot resize windows below the minimum. Has anybody any insights into this behavior?
0 件のコメント
採用された回答
Jan
2011 年 11 月 15 日
編集済み: Jan
2013 年 7 月 26 日
This is not a valid definition of the ResizeFcn:
'ResizeFcn',@ResizeFcn',@cbFigResize, ?!
You can use this to limit the figure size:
jFrame = get(handle(gcf), 'JavaFrame');
try
jProx = jFrame.fFigureClient.getWindow();
catch
jProx = jFrame.fHG1Client.getWindow();
end
jProx.setMinimumSize(java.awt.Dimension(600, 560));
4 件のコメント
Kyungjoon Kim
2012 年 3 月 23 日
I received this error message..
No appropriate method, property, or field fFigureClient for class
com.mathworks.hg.peer.HG1FigurePeer.
and I found following script..
jFrame = get(handle(gcf), 'JavaFrame');
jProx = jFrame.fHG1Client.getWindow();
jProx.setMinimumSize(java.awt.Dimension(600, 560));
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!