Problems with a resize function callback
Show older comments
Hi,
I'm developing a programmed GUI (using the nice GUI toolbox layout available on file exchange). What I want to do is to define minimal length and minimal height of the GUI figure to automatically resize it to avoid displaying problems when the user resize the screen.
To do so, I defined the following resize function callback associated to the figure GUI (I use nested functions, so it is not a variable problem)
function myGUI
mainFig=figure('Position',[139 122 1204 675]);
set(mainFig,'ResizeFcn',@Resize_clbk);
min_length=1200;
min_heigth=600;
%[.....]
function Resize_clbk(hObject,Event)
actual_pos=get(hObject,'Position');
if actual_pos(3)<min_length
set(hObject,'Pos',[actual_pos(1:2) min_length actual_pos(4)]);
end
if actual_pos(4)<min_heigth
set(hObject,'Pos',[actual_pos(1:3) min_heigth]);
end
end
end
This function works nice when I resize the figure from both rigth and bottom borders of the window, but it doesn't works any time when I resize the window from the left or top border, or any corner.
Does anyone have a solution ?
Thank's in advance for your help ^^
Accepted Answer
More Answers (1)
Julien
on 6 Oct 2012
6 Comments
Jan
on 6 Oct 2012
I do not have 2012b for testing this by my own. Please try:
FigH = gcf;
drawnow;
jFrame = get(handle(FigH), 'JavaFrame');
jFrame.setMinimumSize(java.awt.Dimension(200,200));
On one hand this is pure guessing, on the other hand this will not run with "all" Matlab versions. Older Matlab versions require the figure proxy. I assume Yair knows more details.
Julien
on 6 Oct 2012
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!