MATLAB ResizeFcn callback fails
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Jan
el 15 de Nov. de 2011
Editada: Jan
el 26 de Jul. de 2013
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 comentarios
Kyungjoon Kim
el 23 de Mzo. de 2012
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));
Más respuestas (0)
Ver también
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!