> How can I create a JFrame that is centered on the
> screen?
JFrame frame = ...;
frame.setLocationRelativeTo(null);
See the API doc of java.awt.Window#setLocationRelativeTo.
JFrame inherits that method from java.awt.Window.
> It appear up on the left corner of screen. Why?
Because the default position of a JFrame is (0,0).

Signature
"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')
Knute Johnson - 19 Jan 2006 17:02 GMT
>> How can I create a JFrame that is centered on the
>> screen?
[quoted text clipped - 8 lines]
>
> Because the default position of a JFrame is (0,0).
And remember that you have to pack or size it before you call
setLocationRelativeTo().

Signature
Knute Johnson
email s/nospam/knute/
>How can I create a JFrame that is centered on the
>screen?
>It appear up on the left corner of screen. Why?
see http://mindprod.com/jgloss/coordinates.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
palmis - 23 Jan 2006 08:48 GMT
Thank you very much.
palmis