• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to make JFrame get to the center of screen

 
Chaithika Prabudda
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
easiest way is

frame.setLocationRelativeTo(null);

but.....

the frame must have a size prior to that line, either setSize(), or pack()
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that a question or a tip?

It is much easier if you are using 1.4+
Just use
 
Paper has not yet been outlawed – so let your Java Swing application print with wild abandon: JPDF
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!