>>>>> "Olivier" == Olivier Allain <[EMAIL PROTECTED]> writes:
Olivier> Would you know how to set a minimum size to a JFrame?
I feel it's best to handle window sizes in two different ways,
depending on whether there is a JTable or a JList, or similar
components, on the window. The issue with JTable/JList is that it's
hard for a program to know what the real "minimum" size is.
In that case, I would set properties that specify the exact frame
width and height. You would determine those optimal values by testing
on each particular platform and locale you deploy to. I wouldn't
bother with setting or constraining a "minimum" size for these
windows.
However, if the dialog does not contain JTable or JList components,
then I think it's more likely that the "preferred size" of the window
(the sums of all the preferred sizes of the components) is likely what
you want to have as the "minimum size" of the window.
In that situation then, you would like to build something that watches
when the user tries to resize the window, and stops them when they try
to make the window smaller than the preferred size.
In X Windows, you can actually specifically set the minimum size of a
window, and the dragging functionality simply won't let the window
size get smaller than that. This can be done because this works
directly with the window manager.
In Java, however, you can't control the minimum window size through
the window manager, you can only take action after the user has
finished resizing the window (released the drag operation).
So, in the past, I've implemented this with the following elements
(loosely described):
Register the current size of the window as the minimum size. Add a
ComponentListener to the window. In the "componentResized()"
callback, get the new size of the window and the minimum size. If the
new size is smaller, resize it to the minimum size.
If you don't care about reusable code or garbage collection, then it
could be as simple as this. Paying attention to those factors
requires giving it a little more thought.
--
===================================================================
David M. Karr ; w:(425)487-8312 ; TCSI & Best Consulting
[EMAIL PROTECTED] ; Java/Unix/XML/C++/X ; BrainBench CJ12P (#12004)
_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing