Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

JFrame centered on the screen

Thread view: 
palmis - 19 Jan 2006 16:11 GMT
How can I create a JFrame that is centered on the
screen?
It appear up on the left corner of screen. Why?

Palmis
Thomas Fritsch - 19 Jan 2006 16:30 GMT
> 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/

Roedy Green - 19 Jan 2006 17:13 GMT
>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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.