• 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown

being notified of screen resolution changes

Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

We have a swing application, where component sizes are set relative to screen size (this is a *strict* requirement from the customer).
Example: some frame should occupy exactly 1/2 the screen width & height. So (eliminating insets for simplicity):

The problem is, it doesn't work when user changes screen resolution at runtime.
For instance:
1. Invoke the program with a 800x600 resolution: frame will pop up with 400x300 size
2. While frame is showing, change screen resolution (through the operating system) to 1280x960
3. Now, of course, frame is still 400x300 , which is no longer half the screen. Customer would like to to be fixed (1280/2 , 960/2).

Could anyone offer a solution to this ?
In particular, is there any sort of event we can catch to be notified of screen resolution changes ?
(I have considered overriding the frame's paint(Graphics) method, because I've noticed that, at least on winXP, frames are minimized & then maximized when resolution changes; which triggers a call to paint(). So one could override paint() so that it re-checks frame size... but this does not seem very elegant ).

Thanks in advance
    Bookmark Topic Watch Topic
  • New Topic