MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / center

Method center

ij/src/main/java/ij/gui/GUI.java:71–81  ·  view source on GitHub ↗

Positions the specified window in the center of the screen that contains target.

(Window win, Component target)

Source from the content-addressed store, hash-verified

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. */

Callers 5

buildTreePanelMethod · 0.95
ImageWindowMethod · 0.95
centerOnImageJScreenMethod · 0.95
showDialogMethod · 0.95
showDialogMethod · 0.95

Calls 4

getMaxWindowBoundsMethod · 0.95
getSizeMethod · 0.65
maxMethod · 0.45
setLocationMethod · 0.45

Tested by

no test coverage detected