On Mon, 11 Jun 2007 09:28:06 -0700, Rich <Ri**@discussions.microsoft.com>
wrote:
If I create a form in Java with controls like Panels, textboxes... when I
stretch/shrink the form, all the controls can grow/shrink - along with
the
text contained in the textboxes. This is convenient for resizing a form
for
different screen resolutions.
A suggestion:
You are misusing the term "aspect ratio", which describes the ratio
between the width and the height, using it instead to simply describe
scaling of the window.
It is true that if you can accomplish the scaling, you will also likely
want to control the aspect ratio. But it appears from your question that
your primary concern is to control the scaling.
You will get better responses if you use the right terminology in your
question, since if you are using the wrong terminology, some people who
might know the answer to your question may just skip over your post
thinking they don't.
As far as your specific question goes, I don't know the answer off the top
of my head. You can accomplish _part_ of what you're asking about by
using the various the anchoring properties in the controls on your form.
I suppose you could combine that with some code in the Resize event that
changes the font size for the form as a function of the size relative to
the original size, but I've never tried this myself. My recollection is
that you can have the child controls inherit the parent's font, but if I'm
wrong about that you can easily enumerate all the children and set their
font explicitly.
And as I alluded to, if you do all that you may also want to include code
in the Resize event that restricts the new size to one with an aspect
ratio that is identical to the original aspect ratio.
Pete