> Hi all,
>
[quoted text clipped - 14 lines]
> setLocationRelativeTo, it gets perfectly centered with the mother
> window.
Given that pack()..
"Causes this Window to be sized to fit
the preferred size and layouts of its
subcomponents. "
..I consider your result unsurprising.
I would generally pack() a frame before
it is setVisible(true), let alone before
attempting to set its location.
> Does anybody knows what is the difference for java when I swap those
> lines?
One works as advertised, the other is
expected (by my reading of the JavaDocs)
to produce unsatisfactory results.
Call pack() first, then the setLocationRelativeTo
method can have a good idea how big the (J)Frame
needs to be (and 'centering' it based on the
position of other components becomes anything
more than guesswork).
Andrew T.