aspose file tools
The moose likes Swing / AWT / SWT and the fly likes being notified of screen resolution changes Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "being notified of screen resolution changes" Watch "being notified of screen resolution changes" New topic
Author

being notified of screen resolution changes

Sol Mayer-Orn
Ranch Hand

Joined: Nov 13, 2002
Posts: 310
Hi,

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
 
I agree. Here's the link: http://jrebel.com/download
 
subject: being notified of screen resolution changes
 
Similar Threads
Middling The JFrame
Graphics Graphics Graphics - Where are my circles?
ideas wanted on making this custom JTable cell renderer more efficient
problem in minimizing & maximizing frame.
Is it worth using this initialization block?