• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Window Size and Location

 
Dave Teare
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good day Y'all,
I have a few simple questions (I hope!):
How do I set the default window size for my FBN Swing UI? Currently the screen is sized to fit exactly the size required by the components contained within it. While this does work, I find it distracting to have the window change sizes everytime I switch to a new page (i.e. from the 'search flights' pane to the 'flight results' pane.)
Secondly, how do I set the location the newly created window appears? Every time I start my FBN UI, the window is always in the top left corner. I would like it to start centered in the screen.
Thanks in advance!
Dave.
 
Pete Lyons
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use this method in your JFrame subclass:

See the methods setSize() and setPreferredSize() if you don't want to rely on pack().
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic