how to limit which uicontrols are stretched when a GUI window is resized

I am working on a GUI and having problems when the window is resized. There is an image in the middle of the GUI, with buttons above and below. When the window is resized what I'd ideally like is the image to stretch, but the buttons above and below to remain the same size.
I can't do it by specifying character units on the buttons and normalized units on the image. I don't see a way of 'anchoring' the controls together (like you can do in Java).
I think one way would be to recalculate the positions of all controls in the window resize function. But before I try to tackle that I was hoping someone could come up with a better (easier) way.
I appreciate any suggestions. Thanks.
Michael

 채택된 답변

Arthur
Arthur 2012년 10월 14일

0 개 추천

If you place all your uicontrols in a uipanel, you only have to change the position of your uipanel in the resizeFcn. Saves you a lot of work!

댓글 수: 3

Sorry it took me so long to get back to this. Thanks for your suggestion. Do you think I should have 3 panels - one for the top row of buttons, one for the bottom row of buttons, and one for the center image? Is there a way to prevent a panel from stretching during a window resize?
Arthur
Arthur 2012년 10월 17일
편집: Arthur 2012년 10월 17일
I assume you are using GUIDE to make your GUI?
Probably the best way is like this: Make a uipanel for the top buttons, and one for the bottom buttons. The image doesn't need to be in an panel. In GUIDE, choose ResizeFcn as resize behavior (Tools -> GUI options -> rezie behavior). This means that no object will be resized or moved if you change window size, unless it is specified in the ResizeFcn. To have the behavior you described, the ResizeFcn needs to change the position of the Top panel, and the position of the image. It is probably not neccesary to change the position of the bottom panel.
It took me a month to get back to this, but your answer was perfect. Worked exactly as described. The link you gave was also very helpful. Thanks Arthur!
Michael

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Convert Image Type에 대해 자세히 알아보기

질문:

2012년 10월 14일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by