This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Center a JFrame  ... Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Center a JFrame  ..." Watch "Center a JFrame  ..." New topic
Author

Center a JFrame ...

Miguel Enriquez
Ranch Hand

Joined: Mar 13, 2004
Posts: 71
hi friends.

i call a JFrame:

Expediente JFexpediente = new Expediente();
JFexpediente.pack();
JFexpediente.setVisible(true);

my question is how show JFExpediente centered in the screen? actually show at the left top.

Thanks
Miguel Enriquez
Ranch Hand

Joined: Mar 13, 2004
Posts: 71
Expediente JFexpediente = new Expediente();
JFexpediente.pack();
JFexpediente.setLocationRelativeTo(null);
JFexpediente.setVisible(true);


setLocationRelativeTo(null) is my friend thanks
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8438

Originally posted by Miguel Enriquez:
Expediente JFexpediente = new Expediente();
JFexpediente.pack();
JFexpediente.setLocationRelativeTo(null);
JFexpediente.setVisible(true);


setLocationRelativeTo(null) is my friend thanks


Or you call setVisible and then call pack.


[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Center a JFrame ...
 
Similar Threads
closing jframe with button question.
JTable doesn't load on JFrame
Initial Window State - JFrame
internet info in application
JPanel and JFrame