JDK-4487771 : Window.setLocationRelativeTo() doesn't center Windows correctly
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2001-08-03
  • Updated: 2005-06-15
  • Resolved: 2005-06-15
Related Reports
Duplicate :  
Description
From inspecting the code, it looks as if there are a number of problems with the way Window.setLocationRelativeTo() centers a Window (i.e. when Component is null):

* it should retrieve the screen bounds using Window.getGraphicsConfiguration().getBounds(), which will return the bounds of the screen the Window is on, rather than the primary screen
(and)
* it should account for the screen insets using the new 1.4 Toolkit.getScreenInsets() to account for the screen inets
(or alternatively)
* it should use the new 1.4 GraphicsEnvironment.getCenterPoint() and getMaximumWindowBounds() methods, which should take care of most of the calculations.

Comments
EVALUATION After the fix for 6177452 the window is centered in the screen (when Component is invisible or null) by using GraphicsEnvironment.getCenterPoint() method. See the CCC request for 6177452 at http://ccc.sfbay/6177452 for more information. ###@###.### 2005-06-15 09:32:22 GMT
15-06-2005