• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

get window on viewable screen

 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am writing my GUI today, been at it for a day or two working off of previous work. I struggled earlier trying to get the constructor to place something reasonable on the screen. I got one code version to work, that was months ago. Here is what is probably useable from the earlier effort:

Probably the call to super.getSize() is in the wrong place and should be moved to refresh() / updateUI or something.

I want to center on the screen using a default range of 640/480 to 1024/768 - the user can resize if uncomfortable. All reviews welcome.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you just want to center the frame on the screen (at whatever resolution),
ensure the frame is sized:
frame.pack(); or
frame.setSize(w,h);
then
frame.setLocationRelativeTo(null);

note: the order must be
sized
location

other way around and it won't work
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is where I placed your advice temporarily in my code, I thought that sizing has to be passed useable parameters. First efforts resulted in miniature windows or that type of first effort result. The code other than the snippet from you is what I had before posting.

I have today to work on this.

{ message edit: I worked all day on this, tracers put in the code show ( Window width: 648.0 / Window height: 486.0 ) but the window shows up taking all the screen area. }
[ May 13, 2008: Message edited by: Nicholas Jordan ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic