This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

what is this for: setLocationRelativeTo()  RSS feed

 
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as according to the question.

what is it for anyway?
i checked on the api of j2se1.5.0, it explained:
Sets the location of the window relative to the specified component. If the component is not currently showing, or c is null, the window is centered on the screen. If the bottom of the component is offscreen, the window is placed to the side of the Component that is closest to the center of the screen. So if the Component is on the right part of the screen, the Window is placed to its left, and visa versa.

so what is it means? cos i can't get the meaning. Anyone have the simple example to show me?

Regards
Nicky Eng
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this method set the location of dialog in respect of parent dialog.
and rest of the things are very much cleared in your question.


Prashant
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setLocationRelativeTo(null) is commonly used to center the gui on the screen.

much better than getting screen size then adding a formula for setLocation(int,int)

only 'gotcha' is the gui must have a size prior to calling setLocationRelativeTo(null),
either setSize(int,int) or pack(),otherwise the top-left corner of the gui
will be at the center
 
Nicky Eng
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i see.

thank you very much.

so setLocationRelativeTo(null) is used to center frame in the screen.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!