• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

what is this for: setLocationRelativeTo()

 
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i see.

thank you very much.

so setLocationRelativeTo(null) is used to center frame in the screen.
 
reply
    Bookmark Topic Watch Topic
  • New Topic