• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to prompt login frame in the middle of screen

 
ravi v kumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

i have to prompt the login frame in the middle of the screen
but by default the frame is displayed at the left top

is there any code apllied to change?

plz give suggestion

with regards
ravi
 
Amuthan Karunanithi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();]

The piece of code will give you screen size and using that & your frame size you can find out the (x,y) position to center your frame.

You may use "frame.setPosition(x,y)" to make it in the middle.
 
Luca Zappa
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since Java 1.4 you can use:

mainFrame.setLocationRelativeTo(null);
[ December 15, 2004: Message edited by: Luca Zappa ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!