Positions the specified window in the center of the screen that contains target.
(Window win, Component target)
| 69 | |
| 70 | /** Positions the specified window in the center of the screen that contains target. */ |
| 71 | public static void center(Window win, Component target) { |
| 72 | if (win == null) |
| 73 | return; |
| 74 | Rectangle bounds = getMaxWindowBounds(target); |
| 75 | Dimension window = win.getSize(); |
| 76 | if (window.width == 0) |
| 77 | return; |
| 78 | int left = bounds.x + Math.max(0, (bounds.width - window.width) / 2); |
| 79 | int top = bounds.y + Math.max(0, (bounds.height - window.height) / 4); |
| 80 | win.setLocation(left, top); |
| 81 | } |
| 82 | |
| 83 | /** Positions the specified window in the center of the |
| 84 | screen containing the "ImageJ" window. */ |
no test coverage detected