Re: Is there something better than ComponentListener on Resized
On 10/1/2013 8:39 AM, email@example.com wrote:
On Monday, September 30, 2013 11:29:16 AM UTC-4, Eric Sosman wrote:
Perhaps it's time to ask a question: Why do you think it's a good idea to
prevent the user from arranging his own screen as he pleases? Does your program
understand the user's needs and desires better than he himself does?
I want to prevent the user from horizontally resizing the window beyond a certain width because (if I didn't) anything to the right of my two tables would be a a solid gray color of nothing.
So, without the functionality that I want, if the user resizes the window it will look somthing like this exaggerated example:
Where I represent a table with  and gray solid areas are represented by |.
Maybe the user will find the blank gray expanses soothing?
In any event, they're of his own making -- and he can un-make
them again if he finds them objectionable. I sincerely doubt
that your efforts to protect him from his own faulty aesthetic
sense are worth while.
The code that I've, unsuccessfully, tried to use is similar to the code here:
Notice that this page is in a section whose title is
"Lesson: Layout Out Components *Within* a Container" [emphasis
mine]. You can control the sizes and layouts of things *inside*
a top-level container pretty closely, but the TLC itself is a
creature of the native windowing system, sized and positioned
(and decorated, hidden, revealed, ...) by that native system.
You're free to provide hints -- for example, the layout manager
of the frame's content pane can suggest the pane's dimensions --
but the native windowing system is not obliged to honor your
suggestions. (This is viewed as a Good Thing, because it gives
your desktop app a fighting chance of being usable on a teeny-
tiny phone screen, for example.)
To put it more simplistically: Java doesn't own "the screen"
and has no layout manager for it.